2 Replies Latest reply on Oct 10, 2017 11:00 PM by Dan Rodney

    Get Packaged Folder Path [JS]

    Dan Rodney Adobe Community Professional

      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.

        • 1. Re: Get Packaged Folder Path [JS]
          Laubender Adobe Community Professional & MVP

          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

          • 2. Re: Get Packaged Folder Path [JS]
            Dan Rodney Adobe Community Professional

            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!