Skip to main content
Participant
Jan 14, 2023 4:09 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
brian_p_dts
brian_p_dtsCorrect answer
Community Expert
Jan 14, 2023 4:12 PM UTC

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. 

4 replies

Community Expert
Jan 16, 2023 3:04 PM UTC

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 )

Translate
rob day
Community Expert
Community Expert
Jan 14, 2023 4:44 PM UTC

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)
    }
};

 

Translate
DTPtutorialyCZ-L.Zalesky
Inspiring
Jan 14, 2023 11:45 PM UTC

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

#miNerikejZeToNejde

 

Translate
brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
Jan 14, 2023 4:12 PM UTC

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. 

Translate