9 Replies Latest reply on Jul 10, 2013 12:14 PM by shilpa25

    Alert link undefined path

    shilpa25 Level 1

      Hi Forum,

       

      This is the one i have to alert the filePath of the links (links.everyItem placed in a document).

       

      My intention is to "alert only the links which is not in a path" defined inside script.

       

       

      try {

      {

      var theLinks = app.documents[0].links;

      pathL= Folder("C:\\Documents and Settings\\Desktop")

      for (var i = 0; i < theLinks.length; i++)

      {

      //theLinks[i].update();

      if(theLinks[i].filePath.parent ! = pathL.filePath)

      //{

      alert(theLinks[i].filePath);     //   I want to get alert for the links which is not in pathL.filePath)

      //}

      }

      }

      } catch (e) {}

       

      thanks forum,

        • 1. Re: Alert link undefined path
          shilpa25 Level 1

          Well I have also check this way.

           

          if(theLinks[i].filePath ! = pathL)

          {

          alert("One of the image is not linked to pathL);     //   I want to get alert for the links which is not in pathL.filePath)

          }

           

           

          Forum any help on this, to find the image linked to the different Path.

          • 2. Re: Alert link undefined path
            rajnikids Level 1

            Hello,

             

            I do have this bit from the below link;

             

            http://20.adobe-scripting-indesign.overzone.net/filtering-alerting-upon-link-path-t2157.ht ml

             

            try with this.

             

            try {

            {

            var theLinks = app.documents[0].links;

            myserver = "/Users/wleastudio/Desktop"

            for (var i = 0; i < theLinks.length; i++)

            { theLinks[i].update();

               

                if(theLinks[i].filePath.indexOf(myserver) == -1)

                //{ confirm("The file path doesn't point to the server " + myserver + "\r" +"shall we continue ?"); }

                alert(theLinks[i].filePath); } }// }

            } catch (e) {}

            • 3. Re: Alert link undefined path
              shilpa25 Level 1

              Hey rajnikids!

               

              This is checking the links and alerting "filePath" of each image.

               

              I just need to get "alert only for the links which is placed from a different path" apart from the path mentioned in my script (pathL= Folder("C:\\Documents and Settings\\Desktop").

               

              eg. If there are 10 images placed in a document,  out of 10, 9 images are placed from a location (pathL= Folder("C:\\Documents and Settings\\Desktop"))

              and 1 image is placed from a different location. I just want to get alert only for that image because it is not placed from a location as defined inside the script.

               

              many thanks for your reply

               

              and looking forward for the solution from forum.

              • 4. Re: Alert link undefined path
                Jump_Over Level 5

                Hi,

                 

                I think rajnikids gave you a good solution.

                 

                Just edit this line:

                myserver = "/Users/wleastudio/Desktop";

                to make:

                myserver = "/Documents and Settings/Desktop"

                 

                code is alerting every link which doesn't match this path.

                 

                rgds

                Jarek

                • 5. Re: Alert link undefined path
                  shilpa25 Level 1

                  Hi Jarek!

                   

                  thanks for your feedback,

                   

                  I tried with the below code and i'm using mac.

                   

                   

                  try {

                   

                  {

                   

                  var theLinks = app.documents[0].links;

                   

                  myserver = "/Users/mydesktop/Desktop"

                   

                  for (var i = 0; i < theLinks.length; i++)

                   

                  { //theLinks[i].update();

                   

                  if(theLinks[i].filePath.indexOf(myserver) == -1)     // jarek , here why we use -1,

                   

                      //{ confirm("The file path doesn't point to the server " + myserver + "\r" +"shall we continue ?"); }

                   

                      alert("One of the image is not linked from Desktop"); } }// }

                   

                  } catch (e) {}

                   

                  and again it find all the links and giving alerts.. Not the particular only one which is from different path.

                   

                  Please help on this..

                  • 6. Re: Alert link undefined path
                    Jump_Over Level 5

                    Hi,

                     

                    You have to be sure your path string is written correctly.

                    run this line and choose any folder on your Desktop:

                     

                    Folder.selectDialog();

                     

                    check ESTK console where chosen path should be written.

                    Compare it to myserver = ... string

                     

                    String.indexOf(substring) = -1 means substring is not found inbetween string,

                    otherwise it returns index of found position of substring.

                     

                    rgds

                    Jarek

                    • 7. Re: Alert link undefined path
                      shilpa25 Level 1

                      Hi Jarek!

                       

                      Then again i tried with your advice.

                       

                       

                      {

                       

                      var theLinks = app.documents[0].links;

                       

                      myT = Folder.selectDialog();

                      mypath = Folder.toString (myT);  // i think im messing up here

                      myserver = mypath.toString();  // i think im messing up here

                      for (var i = 0; i < theLinks.length; i++)

                       

                      {  

                       

                          if(theLinks[i].filePath.indexOf(myserver) == -1) {

                       

                               alert(""); } } }

                       

                      And again after choosing the folder, the alert is produced to all the images, and not exactly to the images which is from different path after choosing the select Dialog.

                       

                      My request is to find only the images which is placed from a different location. (should not alert to the path specified by select Dialog).

                       

                      many many thanks Jarek!.....

                      thanks in advance.

                      • 8. Re: Alert link undefined path
                        Jump_Over Level 5

                        Hi,

                         

                        use this:

                        var theLinks = app.documents[0].links,
                        myT = Folder.selectDialog(),
                        myPath = myT.path+"/"+myT.name,
                        currPath, i;
                        
                        for ( i = 0; i < theLinks.length; i++ )
                             {  
                             currPath = File(theLinks[i].filePath).path;
                             if(currPath.indexOf(myPath) == -1) 
                                  alert(theLinks[i].name +"\r" + currPath.fullName + "\r" + myPath);
                             }
                        

                         

                        the problem was to compare paths written with the same notation

                         

                        rgds

                        Jarek

                        • 9. Re: Alert link undefined path
                          shilpa25 Level 1

                          Hi Jarek!

                           

                          many apologise for the delayed response...

                           

                          here its raining heavily and b'cuse of that i have to windup my office eariler and came home and replying you...

                           

                          many thanks for the support and timely help....