7 Replies Latest reply on Jul 29, 2014 4:29 AM by Sajeev Sridharan

    filepath

    Dapeamel

      Hello guys

       

      I use this  script to get my filepath

      var TargetFolder= Folder.selectDialog("Select a target"),  /target
      alert(TargetFolder.fsName);
      

       

      the result:

      /users/test/desktop/321423/source/copy here/

       

       

      how do I filter in the alert so I just grep /321423/source/

       

      thank you in advance

        • 1. Re: filepath
          Sajeev Sridharan Level 4

          I am not clear, may be you are looking like this,

           

          var TargetFolder= Folder.selectDialog("Select a target");

          //alert(TargetFolder.fsName);

           

          var targetFileName = TargetFolder.fsName.toString();

           

          targetFileName = targetFileName.replace("/users/test/desktop/", "");

          targetFileName = targetFileName.replace("copy here/", "");

            alert(targetFileName);

           

          Vandy

          • 2. Re: filepath
            Dapeamel Level 1

            this is what I am looking for but the code but it doesnt really work in adobe cs 4

            but its better with the code select like 4 o 5 element in the array,

            is it possible to select that in the array

            • 3. Re: filepath
              Sajeev Sridharan Level 4

              I think you need only parent and grand parent folder, try this

               

              var TargetFolder= Folder.selectDialog("Select a target");

              var parentFolder = TargetFolder.parent.name;

              var grandParentFolder = TargetFolder.parent.parent.name;

              var grepFolder = "/" + parentFolder + "/" + grandParentFolder + "/";

              alert(grepFolder);

               

              Vandy

              • 4. Re: Re: filepath
                Dapeamel Level 1

                thanks bro

                 

                I guess I wasn't clear with my question at all

                 

                is it way to form the script, instead of use parents etc.

                it just picks in the array red marked text.

                cause the filepath isnt the same all the time

                 

                the script select the just red colored element

                 

                here are few examples below

                 

                /xxx/xxxx/xxx/xxxx/xxxxx/xxx/xxxx

                /xxxx/xxxxx/xxx/xxxx

                /xxxxx/xxx/xxxx

                /xxx/xxxx


                thank you in advance

                • 5. Re: filepath
                  Sajeev Sridharan Level 4

                  You can select any folder, it doesn't matter, the script will alert the previous (parent) folder name of the selected folder (that is you will get the red colored folder name),

                   

                  var TargetFolder= Folder.selectDialog("Select a target");

                  var parentFolder = TargetFolder.parent.name;

                  alert(parentFolder)

                   

                  Why you are using array? is there any specific reason?

                   

                  Vandy

                  • 6. Re: Re: filepath
                    Dapeamel Level 1

                    yes,

                    I want to filter a part of the path,

                    cause I have created a script that creates a backup_structure

                    so I when I copy files I want the script also copy to the same folder but in the backup,

                     

                    Could you proberly help me out with this?


                    I can pm you the code.

                    i guess you understand when you see the code.

                    • 7. Re: filepath
                      Sajeev Sridharan Level 4

                      send me, I will check and give my feasible solution

                       

                      Vandy