Get Packaged Folder Path [JS]

Community Expert ,
Aug 07, 2017 Aug 07, 2017

Copy link to clipboard

Copied

After a file is packaged using File > Package, I want to do something to the packaged folder. For that I'll need to be get the path of the packaged folder created by the Package command. I know I could completely script the entire packaging process, but if it's possible I'd much rather watch for when the File menu's Package command is used, and then do something.

Is this possible? If so, could you point me in the direction of how? I only need to support Macs on InDesign CC 2017.

Below is what I have so far. I am watching for the Package menu, but I don't know how to get the folder path. (The alert is there to make sure this was working.)

#targetengine 'persistentScopeForPackagingEvent'

var doThis = function(event) {

  alert( 'Event: ' + event.target.name );

};

app.menuActions.item('$ID/Package...').addEventListener('afterInvoke', doThis);

Thanks in advance for any help.


— Adobe Certified Expert & Instructor at Noble Desktop | Web Developer, Designer, InDesign Scriptor
TOPICS
Scripting

Views

600

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 08, 2017 Aug 08, 2017

Hi Dan,

hm. I would attach a listener for:

AFTER_SAVE_A_COPY

to the app and exploit the incoming events.

Property fullName of the event should give you the packaged InDesign document.

Some code to demonstrate this:

#targetengine 'persistentScopeForPackagingEvent'

var afterSaveACopy =

    app.eventListeners.add( "afterSaveACopy" , listenAfterSaveACopy );

var afterInvokePackage =

    app.menuActions.item("$ID/Package...").

    addEventListener("afterInvoke", listenAfterInvokePackage );

var counter = 0;

funct

...

Likes

Translate

Translate
Community Expert ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hi Dan,

hm. I would attach a listener for:

AFTER_SAVE_A_COPY

to the app and exploit the incoming events.

Property fullName of the event should give you the packaged InDesign document.

Some code to demonstrate this:

#targetengine 'persistentScopeForPackagingEvent'

var afterSaveACopy =

    app.eventListeners.add( "afterSaveACopy" , listenAfterSaveACopy );

var afterInvokePackage =

    app.menuActions.item("$ID/Package...").

    addEventListener("afterInvoke", listenAfterInvokePackage );

var counter = 0;

function listenAfterInvokePackage( evt )

{

    $.writeln(counter+" : "+"listenAfterInvokePackage"+" : "+evt.eventType);

    $.writeln(counter+" : "+"listenAfterInvokePackage"+" : "+evt.timeStamp);

    counter++;

};

function listenAfterSaveACopy( evt )

{

    $.writeln(counter+" : "+"listenAfterSaveACopy"+" : "+evt.eventType);

    $.writeln(counter+" : "+"listenAfterSaveACopy"+" : "+evt.timeStamp);

    $.writeln(counter+" : "+"listenAfterSaveACopy"+" : "+evt.fullName);

    counter++;

};

The problem would be to discern between a "regular" Save A Copy and the one the package feature is doing.

Comparing time stamps could be a way perhaps.

Regards,
Uwe

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

LATEST

Sorry for not replying earlier, but this was exactly what I needed. I wouldn't have thought of watching the afterSaveACopy event for that info, but I was able to use that to get my script working. Thank you so much!


— Adobe Certified Expert & Instructor at Noble Desktop | Web Developer, Designer, InDesign Scriptor

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines