8 Replies Latest reply on Oct 30, 2017 3:37 PM by Kasyan Servetsky

    Delete links

    xmlapi

      Our designer sent us a Indesign file and with it a Document Fonts and Links folder.

       

      I noticed that some of the images in the indesign file are the images in the links folder. However, when I delete the links folder, Indesign complains the Links are missing however the images are still displayed in the indesign file. How do I remove the Links folder and link references but keep the images displayed in the indesign file? I tried to delete a link from the Links panel but deleting it also deletes the image from the Indesign page.

        • 1. Re: Delete links
          John Hawkinson Level 5

          Is this a scripting question in sheep's clothing?

           

          It sounds like you're trying to Embed the link? Use the links panel flyout command to do so.

          • 2. Re: Delete links
            xmlapi Level 1

            The linked file is a PSD which is large. If I embed the file, the size of the template also becomes large. I'm guessing the only way is to export it as a JPEG from Photoshop and then embed it?

            • 3. Re: Delete links
              John Hawkinson Level 5

              Again, why is this in the scripting forum? It does not seem to have anything to do with scripting.

               

              Your question just isn't clear.

               

              If you delete the link without embedding it, of course things won't work.

              If you embed the link in the layout, of course the layout will grow by the size of the image.

               

              How else could this work?

               

               

              Since your question doesn't make any sense, perhaps you could explain what you are trying to actually accomplish?

              • 4. Re: Delete links
                Haakenlid Level 3

                I noticed that some of the images in the indesign file are the images in the links folder. However, when I delete the links folder, Indesign complains the Links are missing however the images are still displayed in the indesign file.

                What you see in InDesign when the link is missing is a low resolution preview of the image. You can print or export the preview without linking the proper image, but it will not look pixelated and ugly. You should find the original image and relink it.

                 

                Is it really a problem that the file size of the photoshop file is large?

                 

                There are many ways to reduce the size of an image file, but InDesign will generally crop and resample large images when exporting anyway, so the final pdf will often be much smaller than the original photoshop files used in it.

                • 5. Re: Delete links
                  beto correa Level 1

                  I converted my Linked .ai files to .eps and then reliked them by extension.
                  Now I need to delete the .ai files because I will not use them anymore.
                  Is it possible to do this through scripting without needing a package?

                  below before and after...

                   

                  example.jpg

                  Can someone help me?

                  Grateful

                  • 6. Re: Delete links
                    Kasyan Servetsky Level 5

                    https://forums.adobe.com/people/beto+correa  wrote

                     

                    I converted my Linked .ai files to .eps and then reliked them by extension.
                    Now I need to delete the .ai files because I will not use them anymore.
                    Is it possible to do this through scripting without needing a package?

                    below before and after...

                     

                    example.jpg

                    Can someone help me?

                    Grateful

                    I don't know why do you need this: I'd rather sort the files by type, select and delete them in finder/explorer.

                    Anyway, here's the script:

                    main();
                    
                    function main() {
                        var link, path, file, removed,
                        count = 0,
                        doc = app.activeDocument,
                        links = doc.links;
                        
                        for (var i = links.length - 1; i >= 0; i--) {
                            link = links[i];
                            
                            if (link.name.match(/\.eps$/i) != null) {
                                path = link.filePath.replace(/\eps$/i, "ai");
                                file = new File(path);
                                
                                if (file.exists) {
                                    try {
                                        removed = file.remove();
                                        if (removed) count++;
                                    }
                                    catch(err) {}
                                }
                            }
                        }
                    
                        alert(count + " file" + ((count == 1) ? " was" : "s were") + " deleted.", "Delete AI-files script");
                    }
                    

                    Warning! The ai-files are completely killed by the script so you won't be able to restore them from Recycle bin.

                     

                    — Kas

                    • 7. Re: Delete links
                      beto correa Level 1

                      Dear Kas ...
                      I have tried to do this by finder but there are many .ai files to convert eps. This script will help me a lot.
                      I'll join with the relink script
                      and insert into the workflow.
                      The final script looks like this.

                       

                      -----------------------------------------------------------------

                       

                      var myImages = app.activeDocument.allGraphics;

                       

                       

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

                       

                       

                         var myImage = myImages[i].itemLink;

                       

                       

                         var myNewName = myImage.filePath.replace(/\.ai$/i, "") + ".eps";

                       

                       

                         var myNewLink =  new File (myNewName);

                       

                       

                            if (myNewLink.exists) {

                       

                       

                               myImage.relink (myNewLink);

                       

                       

                               myImage.update();

                       

                       

                            }

                       

                       

                      }

                       

                       

                      main();

                       

                       

                      function main() {

                          var link, path, file, removed,

                          count = 0,

                          doc = app.activeDocument,

                          links = doc.links;

                         

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

                              link = links[i];

                             

                              if (link.name.match(/\.eps$/i) != null) {

                                  path = link.filePath.replace(/\eps$/i, "ai");

                                  file = new File(path);

                                 

                                  if (file.exists) {

                                      try {

                                          removed = file.remove();

                                          if (removed) count++;

                                      }

                                      catch(err) {}

                                  }

                              }

                          }

                       

                       

                          alert(count + " file" + ((count == 1) ? " was" : "s were") + " deleted.", "Delete AI-files script");

                      }

                       

                      -----------------------------------------------------------------


                      Very fast.


                      Thank you very much!

                      To convert .ai to .eps I used this illustrator script below.

                       

                      -----------------------------------------------------------------

                       

                      // script.parent = CarlosCanto // 06/4/2013;

                      // script.forumPost = http://forums.adobe.com/thread/1224874?tstart=0

                       

                      var folder = Folder.selectDialog("Select Source Folder..."); // select folder

                       

                      if (folder==null) {

                                          alert("Good Bye");

                      }

                       

                      else {

                       

                          var files = find_files (folder, ['.ai']);

                       

                                var fileCount = files.length; // count them

                       

                                if (fileCount>0) {

                       

                       

                                          for (i=0; i<fileCount; i++) {

                       

                       

                                  var idoc = app.open(files[i]);

                       

                       

                                  var saveOpts = new EPSSaveOptions();

                       

                       

                                  saveOpts.pdfCompatible = true;

                       

                       

                                  idoc.saveAs( files[i], saveOpts );

                       

                       

                                  idoc.close();

                       

                       

                                          }

                       

                       

                              alert(fileCount + ' file(s) processed');

                       

                       

                                }

                       

                       

                                else {

                       

                       

                                          alert("There are no Illustrator files in this folder.");

                       

                       

                                }

                       

                       

                      }

                       

                       

                      // recurse subfolders - Peter Kharel

                       

                       

                      function find_files (dir, mask_array){

                       

                       

                          var arr = [];

                       

                       

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

                       

                       

                              arr = arr.concat (find_files_sub (dir, [], mask_array[i].toUpperCase()));

                       

                       

                          }

                       

                       

                          return arr;

                       

                       

                      }

                       

                       

                      function find_files_sub (dir, array, mask){

                       

                       

                          var f = Folder (dir).getFiles ( '*.*' );

                       

                       

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

                       

                       

                              if (f[i] instanceof Folder){

                       

                       

                                  find_files_sub (f[i], array, mask);

                       

                       

                              } else if (f[i].name.substr (-mask.length).toUpperCase() == mask){

                       

                       

                                  array.push (f[i]);

                       

                       

                              }

                       

                       

                          }

                       

                       

                          return array;

                       

                       

                      }

                       

                      -----------------------------------------------------------------


                      Is it possible to leave everything in one indesign script?

                      If that's not possible, fine.


                      It's already very good!

                      Thank you very much!

                      • 8. Re: Delete links
                        Kasyan Servetsky Level 5

                        Yes, of course, it's possible to interact from indy with illy via BridgeTalk so you can keep everything in a single script.

                        I am not at the computer at the moment so cant write any code. But you can find many examples of using bt on my site and here on the forum.

                         

                        -- kas