0 Replies Latest reply on Jan 25, 2011 10:48 AM by tansk02

    script not run within folder

    tansk02 Level 1

      Hi All,

       

      See my below code which i am using for relink my images.

       

      My old images name have following changes, [hyphen] change to [underscore], [solidus] change to [underscore], and [space] change to [underscore].

       

      I am working on InDesing CS4 on Macintosh. My code is working fine if my folder name is one word i.e, Test.

      My code does not work when my folder name  has [underscore]  or [space] i.e, Test_relink.

       

      Can anyone suggest where is the problem is and how to rectify it.

       

      Tansk

      --myCode------

      var myDocLinks = app.documents[0].allGraphics;
      for (l = myDocLinks.length-1; l >= 0 ; l--)
      {
      var myLink = myDocLinks[l].itemLink;
      var myLinkNewName = myLink.filePath.replace(/-/g, "_").replace(/\//g, "_").replace(/ /g, "_");
      var myNewLinks = new File(myLinkNewName);
      if (myNewLinks.exists)
      {
      myLink.relink(myNewLinks);
      try {
      myLink.update();
      }
      catch(e) {_}
      }
      }
      alert("DONE")