Skip to main content
Inspiring
December 20, 2019
Question

Extendscript: Package command

  • December 20, 2019
  • 3 replies
  • 569 views

Hi,

 

Is there any way of invoking the "Package" command that collects for output via Extendscript? I cannot see any reference to this in the documentation; if not, is there any way to simulate packaging of the file by collecting external links?

This topic has been closed for replies.

3 replies

Inspiring
December 20, 2019

Thanks both.
So I ended up going the route of scooping the placed items and placing them in the export folder, then updating the links. For reference:

function exportLinkedItems(doc, folderPath){
    var placedItems = doc.placedItems;
    for (var i = 0; i < placedItems.length; i++){
	var placedItem = placedItems[i];
	var linkedFile = placedItem.file;
	if (linkedFile === null){
		continue;
	}
	var newPath = folderPath + "/" + linkedFile.name;
	linkedFile.copy(newPath);
	var newFile = File(newPath);
	placedItem.file = newFile;
    }
}
Larry G. Schneider
Adobe Expert
December 20, 2019

I'm not sure of the exact syntax but try using the app.executeMenuCommand. 

Lumenn
Inspiring
December 20, 2019

You can try

 

app.executeMenuCommand("Package Menu Item");

 

but it will prompt to the user, with regular Package prompt.

Thanks to @Ten-A we can also include this so it's easier to execute menu commands.

If you want to do it without prompts, then it should be doable with getting all links (placedItems), and saving them in specific folder.