4 Replies Latest reply on Jun 25, 2010 8:38 PM by Anastasiy Safari

    Path to the extension panel's directory from ExtendScript .jsx

    Anastasiy Safari Level 1

      Hi!

       

      Is there a way to get the path to extension panel's folder from the external (or embedded) .jsx script?

      Both $.fileName and  "catch( err ) {  where = File(err.fileName); }" return the path to "Adobe Photoshop CS5".

       

      Thank you!

        • 1. Re: Path to the extension panel's directory from ExtendScript .jsx
          LeeHuang Adobe Employee

          Hi Anastasiy,

           

          I am not sure how to do it in the ExtendScript, but in CSXS extension, you can do the following to get the extension's folder, maybe you can use it since you know how to communicate between ES and AS?

           

           

                         var result:SyncRequestResult = CSXSInterface.getInstance().getSystemPath(SystemPath.APPLICATION);

                         var appData:String;

                         if((SyncRequestResult.COMPLETE == result.status) && result.data)

                         {

                              appData = result.data;

                              trace(appData);

                         }

           

          Thanks!

          lee

          • 2. Re: Path to the extension panel's directory from ExtendScript .jsx
            Anastasiy Safari Level 1

            Thank you, Lee!

             

            It's a pity, my problem is a little bit more complex, and I need to get the path from the javascript, if it's possible.

            • 3. Re: Path to the extension panel's directory from ExtendScript .jsx
              Bob Stucky Adobe Employee

              I read the original post wrong.

               

              This is the function I use for InDesign scripts:

               

              getScriptsFolder = function() {
                  try {
                      var script = app.activeScript;
                      return new Folder( script.parent.parent );
                  } catch(e) {
                      // we are running from the ESTK
                      var script = File(e.fileName);
                      var a = script.absoluteURI.split( "/" );
                      var a1 = [];
                      for ( var i = 0; i < a.length; i++ ) {
                          a1.push( a[ i ] );
                          if ( a[ i ] == "Scripts" ) {
                              a1.push( a[ i + 1 ] );
                              break;
                          }
                      }
                      return new Folder( a1.join( "/" ) );
                  }
              }

               

              Running as a script in ID, it'll just return the scripts folder. But, if that line errors, ES error objects contain a reference to the script File.

               

              I don't know if this will work in the context of a CS Extension panel or not, but it's certainly worth a try.

               

              Bob

              • 4. Re: Path to the extension panel's directory from ExtendScript .jsx
                Anastasiy Safari Level 1

                Thanks, Bob!

                 

                But that doesn't work. app.activeScript again returns the path to "Adobe Photoshop CS5" folder, while scripts in case of a panel are being kept  under CS5Service manager folder, which is, in turn is under [User] or [Common Files] folder on Windows.

                 

                It seems like all paths in the case of the panel mysteriousely lead to "Adobe Photoshop CS5" folder