Skip to main content
Participant
January 14, 2023
Answered

Get the file path of all placed linked files on the page include those within groups

  • January 14, 2023
  • 3 replies
  • 698 views

The following allows gets the file paths of all pageItems where item.hasOwnProperty("graphics")

However, this does not get the file paths for the frames that are within a group on that page.


How can we resolve this? 
Any suggestions or insight would be appreciated. Thank you.

var doc = app.activeDocument;
var viewportBounds = app.activeWindow.activePage.bounds;
var viewportElements = app.activeWindow.activePage.getElements(viewportBounds);
var filePaths = [];
var modifiedFilePaths = [];
var page = app.activeWindow.activePage;
for (var i = 0; i < page.pageItems.length; i++) {
    var item = page.pageItems[i];
    if (item.hasOwnProperty("graphics")) {
        for (var j = 0; j < item.graphics.length; j++) {
            var graphic = item.graphics[j];
            var filePath = graphic.itemLink.filePath;
            // check if file path is already in the array
            if(!filePaths[filePath]) {
                filePaths[filePath] = true;

 

This topic has been closed for replies.
Correct answer brian_p_dts

Iterate through page.allPageItems instead of just page.pageItems;

 

The alternative is to write your own recursive func, but that's what allPageItems is for. 

3 replies

Community Expert
January 16, 2023

Hi together,

how about using this array:

page.allGraphics

Of course you have to check for property itemLink, because with copy/pasted graphics from e.g.an open PhotoShop image selected this should throw an error.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

rob day
Community Expert
Community Expert
January 14, 2023

Hi @SnowDPD , Another option might be to loop through the links and check the linked graphic’s  parentPage:

 

 

var lnks = app.activeDocument.links;
var ap = app.activeWindow.activePage;

for (var i = 0; i < lnks.length; i++){
    if (lnks[i].parent.parentPage == ap && lnks[i].parent.hasOwnProperty("graphics")) {
        $.writeln(lnks[i].filePath)
    }
};

 

Inspiring
January 14, 2023

Open links panel, add filepath column, set shortcut for: get all information from links panel. Done. 

#miNerikejZeToNejde

 

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
January 14, 2023

Iterate through page.allPageItems instead of just page.pageItems;

 

The alternative is to write your own recursive func, but that's what allPageItems is for.