5 Replies Latest reply on Nov 14, 2013 2:56 AM by Abhi_apple

    How to capture image name from the file path of the links in indesign

    Abhi_apple Level 1

      Hi,

       

      I am capturing the complete path of links used in indesign through javascript. However, I need to capture only the image name from the file path.

       

      For example:

       

      Through script I am capturing the path of this image as:

       

      /Users/user-name/Desktop/image.ps

       

      However, I need to capture from this path only the image name i.e. I want only image.ps

       

      I tried doing grep, replace but not too sure how to carry forward.

       

      Any help will be appreciated.

       

      Here is my script through which I am getting the link path.

       

      var myDoc = app.activeDocument;

      var myLinks = myDoc.links;

       

      if (myLinks.length == 0) {

           ErrorExit("This document doesn't contain any links.", true);

      }

      for (var i = myLinks.length-1; i >= 0 ; i--) {

      var currentLink = myLinks[i];

      var LinkPath = currentLink.filePath;

      alert (LinkPath);

      }

      }

       

      Regards,

       

      Abhi