4 Replies Latest reply on Aug 5, 2013 7:10 AM by Dave Saunders

    Get name of the folder after parent.

    artCraft2 Level 1

      Hi forum.

       

      I need a great help from you.

       

      If I could get the name of the folder which is between the Desktop and the indesign files where it ls saved...

       

      eg.

       

      /Users/wleastudio/Desktop/rantac/acb.indd.

      I need to get the folder name highlited in red and alert...

       

       

       

      if this is straight away on desktop i can do alert easily like below..

       

      name = Folder("/Users/wleastudio/Desktop/");

      if(app.activeDocument.filePath == name.path+"/" + name.name) {

          alert ("The document is in Desktop"), exit;

          }

       

      if, the document is saved inside a folder on a desktop, that's the problem, i'm finding to difficult to find folder name and get alert..

      /Users/wleastudio/Desktop/rantac/acb.indd.

       

      Many thanks in advance

        • 1. Re: Get name of the folder after parent.
          Jump_Over Level 5

          Hi,

          artCraft2 wrote:

          ...

          if this is straight away on desktop i can do alert easily like below..

          ...

           

          It is still straight way:

          last folder name:  app.activeDocument.filePath.parent.name

          last folder:  app.activeDocument.filePath.parent

           

          You could step back using parent.parent and so on...

           

          Jarek

          • 2. Re: Get name of the folder after parent.
            artCraft2 Level 1

            A great help in fact,

            helped me a lot...

             

            try {

            if(app.activeDocument.filePath.parent.parent.parent.parent.parent.parent.name =="Desktop") {

                alert ("Correct Location " + app.activeDocument.filePath);

             

                }

            else {

            alert("the Job is wrong Location"  +"\r" +"currently here it is" + app.activeDocument.filePath)

            }} catch (e) {}

            • 3. Re: Get name of the folder after parent.
              artCraft2 Level 1

              Hi,

               

              Many many apologies for the delayed reponses...

               

              Your help support me a lot!!!.. but,

               

               

              try {

              if(app.activeDocument.filePath.parent.parent.parent.parent.parent.pare nt.name =="Desktop") {

                  alert ("Correct Location " + app.activeDocument.filePath);

               

                  }

              else {

              alert("the Job is wrong Location"  +"\r" +"currently here it is" + app.activeDocument.filePath)

              }} catch (e) {}

               

               

               

              When the parent folder name is mentioned" the script catches and alerts.

               

              if the "indesign doc" is not in the parent folder. i.e. it may be inside the folder on the desktop or download folder of some other folder...

               

              The alert says"null folder" not found.

               

              Many thanks

              • 4. Re: Get name of the folder after parent.
                Dave Saunders Level 4

                If you follow the parental trail up from any folder, you'll eventually reach the top. The top is null. So, your statement is failing because you are assuming that that your file is sufficiently deep into the file system that the parent of the parent of the parent of the parent of the parent of the parent of the folder holding your file isn't over the top, but apparently it is.

                 

                Dave