4 Replies Latest reply on Mar 7, 2010 11:27 AM by mileking

    [JS CS3] how to extract info from scriptsList Array

    mileking

      Hi to everybody,

       

      just a silly question: How can I extract fileName and filePath from scriptList property and display them in a Alert box?

        • 1. Re: [JS CS3] how to extract info from scriptsList Array
          Peter Kahrel Adobe Community Professional & MVP

          app.scriptPreferences.scriptsList returns a two-dimesnional array. The first dimension contains contains script file names with symbolic pathnames (e.g. "User:Scripts Panel:blot.jsx"), the second dimension, script file names and literal path names (e.g. "~/AppData/Roaming/Adobe/InDesign/Version%206.0/en_US/Scripts/Scripts%20Panel/blot.jsx"). To display paths and names, do this: So this would do:

           

          f = app.scriptPreferences.scriptsList;

          s = "";

          for (i = 0; i < s.length; i++)

             s += decodeURI (f[i][1]) + "\r";

          alert (s);

           

          Path names can be long, though, so it will look ugly on your screen. Why do you want this, by the way, if you don't mind my asking?

           

          Peter

           

          PS: decodeURI () is not necessary, but displays spaces andany accented characters better.

          1 person found this helpful
          • 2. Re: [JS CS3] how to extract info from scriptsList Array
            mileking Level 1

            Hi Peter,

             

            the script you wrote won't work (I get an empty Script Alert box). This is the script I've

            tried, looks a little primitive but I was getting results in the format you wrote, but

            I didn't got the script names and path (which I initially wanted) from the default "C:\Documents and Settings\Administrator\Application Data\

            Adobe\InDesign\Version 5.0\Scripts\Scripts Panel" directory, where CS3 keeps its user scripts:

             

            var myTable = new Array;
            var myData = new Array;
            myTable = app.scriptPreferences.scriptsList;
            for (i=0; i<20; i++) {
            myData = myTable[i,i];
            var fileName = myData[0];
            var filePath = myData[1];
            alert(fileName + " // " + filePath);
            }

            "i" doesn't have to be below 20, I put it just for demonstration.

             

            About your question, I was a liitle curious how to get names of the scripts which I have a lot, typed from Scripting Guide book

            which eventually have a certain number lot of typos, so I had to re-read a couple of times some example scripts to make them work.

             

            Thank you for help

             

            mileking

            • 3. Re: [JS CS3] how to extract info from scriptsList Array
              Peter Kahrel Adobe Community Professional & MVP

              Ah, that should have been

               

              for (i = 0; i < f.length; i++)

               

              (f instead of s). You'll see the pathnames starting with a swung dash (~), which is JS's way of pointing to the user's folder. You can read more about folders and their names in the JS tool guide, see under Help in the ESTK help menu.

               

              app.scriptPreferences.scriptsList returns the scripts in both the user folder and the application folder. app.scriptPreferences.scriptFolder returns just the scripts in the user folder. Mmm -- I think that's the case, anyway. Try before you buy.

               

              Peter

              • 4. Re: [JS CS3] how to extract info from scriptsList Array
                mileking Level 1

                Yep, it's working

                 

                thanks for help

                 

                mileking