4 Replies Latest reply on May 8, 2012 4:15 AM by -hans-

    Relinks images with .eps

    designmon79 Level 1

      Hi All,

       

      I have a document with lots of missing images showing no extensions.

       

      I need to relink those images with .eps. Rest of the image naming is same.

       

      For example:

       

      missing image naming in the document is "art01". I need to relink it with "art01.eps".

       

      I found the below script but when I run this script it gives error (see screenshot). Please help.

       

      error2.png

       

      var i, j;

      for (j=0; j<app.documents.length; j++) {

          doc = app.documents[j];

       

          imgs = doc.links;

          path = doc.filePath;

         

          $.writeln("Processing document "+j+" from path "+path);

       

          for (i=0; i<imgs.length; i++)

          {

              // Missing?

          $.writeln("Image "+i);

              if (imgs[i].status == LinkStatus.LINK_MISSING)

              {

              $.writeln("Missing: "+imgs[i].name);

                  // Do we have a file?

                  imglist = Folder(path).getFiles (imgs[i].name+".*");

              $.writeln("Found "+imglist.length+" possible replacements.");

                  if (imglist.length == 1)

                  {

                      // Oh yeah

                      imgs[i].relink(imglist[0]);

              $.writeln("Relinked to "+imglist[0]);

                  }

              }

          }

      }

        • 1. Re: Relinks images with .eps
          Green4ever Level 3

          check this post,

          http://forums.adobe.com/message/2112118#2112118

           

          This states similar problem... May be helpful for you...

           

          Edit:

          Also check this adobe's page,

           

          http://helpx.adobe.com/indesign/kb/error-cannot-place-file-no.html

           

          Green4ever

          • 2. Re: Relinks images with .eps
            designmon79 Level 1

            I have tried this but it is still not working. It is showing same error.

             

            I have also tried below script from Jongware. It is also showing same error mentioned above.

             

            Please help.

             

             

            More clarification, is there any JS code which can replace missing link (without extension .eps) with .eps images.

             

            Images naming are same. Only difference is missing link doesn't have extension (.eps) and images folder have images with extension (.eps).

             

             

             

            var i, j, searchfolder;
            for (j=0; j<app.documents.length; j++) {
                doc = app.documents[j];

                imgs = doc.links;
                path = doc.filePath;

                $.writeln("Processing document "+j+" from path "+path);
                searchfolder = searchfolder || new Folder(path);
                searchfolder = searchfolder.selectDlg(
                "Find a path to "+doc.name+"'s images. Should contain "+
                    imgs[0].name+".*");

                for (i=0; i<imgs.length; i++)
                {
                    // Missing?
                $.writeln("Image "+i);
                    if (imgs[i].status == LinkStatus.LINK_MISSING)
                    {
                    $.writeln("Missing: "+imgs[i].name+" lookign in "+searchfolder);
                        // Do we have a file?
                        imglist = findAnyFileDownThere(imgs[i].name, searchfolder);
                    $.writeln("Found "+imglist.length+" possible replacements.");
                        if (imglist.length == 1)
                        {
                            // Oh yeah
                            imgs[i].relink(imglist[0]);
                    $.writeln("Relinked to "+imglist[0]);
                        }
                    }
                }
            }
            function findAnyFileDownThere (filename, path)
            {
            var result, folderList, fl;
            result = Folder(path).getFiles (filename+".*");
            if (result.length > 0)
              return result;
            folderList = Folder(path).getFiles(function(item) { return item instanceof Folder && !item.hidden; });

            for (fl=0; fl<folderList.length; fl++)
            {
                    $.writeln("Looking in: "+path+"/"+folderList[fl].name);
              result = findAnyFileDownThere (filename, path+"/"+folderList[fl].name);
              if (result.length > 0)
               return result;
            }
            return [];
            }

            • 3. Re: Relinks images with .eps
              [Jongware] Most Valuable Participant

              Do you see that nowhere in that code of mine the missing piece ".eps" gets added to the missing link name?

              • 4. Re: Relinks images with .eps
                -hans- Level 4

                Hi,

                 

                try this shortened Code. If still running into problems check back the first answer ...

                 

                var theDoc = app.activeDocument;

                var theLinks = theDoc.links;

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

                {

                var aLink = theLinks[i];

                if(aLink.status === LinkStatus.LINK_MISSING)

                {

                    var newFilePath = new File(aLink.filePath + '.eps').fullName; //Systemindependent Path

                 

                     if (File(newFilePath).exists) { 

                aLink.relink(File(newFilePath));       

                     }

                 

                    }

                    }

                 

                Edit: Assumes that the 'EPS'-Files stay at the same location as the NON-Eps-Files (Missing links)