8 Replies Latest reply on Jun 3, 2015 12:50 AM by Laubender

    relink … {look for broken links in this folder: true}

    DBLjan Level 2

      Hello there,

       

      i'm currently automating linking after a server migration with new folder structure, so far so good.

      I have a bunch of folders who contain a huge chunk of that missing files.

      For far as I am, I fetch

       

      set MyBrokenLinks to (every link whose status is link missing)
      repeat with k from 1 to (length of MyBrokenLinks)… 
      

       

      and batch-relink them to specific paths on our new server.
      My script could speed up greatly if I could only use the InDesign-Feature to look in thet new given relink folder for broken links, as shown in my Screenshot.

       

      Am I able to applescript the use this InD-feature?

       

      Bildschirmfoto 2015-06-01 um 10.08.13 Kopie.png

        • 1. Re: relink … {look for broken links in this folder: true}
          AS Scripter Level 1

          -- I've never seen that UI feature scripted, so I always use something like this:

           

          set newFD to "HardDrive2:Links-New:" -- new source folder of links

           

          tell application "Adobe InDesign CS6"

            tell document 1

           

            set eflag to 0

            try

            set myBrokenLinks to object reference of (every link whose status is link missing)

            on error

            display dialog ("No missing links found.")

            set eflag to 1

            return

            end try


            if eflag = 0 then

           

            set oldTIDs to AppleScript's text item delimiters

            set AppleScript's text item delimiters to ":"

           

            repeat with i from 1 to count of myBrokenLinks

            set oldFP to (file path of item i of myBrokenLinks) as string

            set newFP to (newFD & (last text item of oldFP)) as string

           

            relink item i of myBrokenLinks to alias newFP

            end repeat

            update every link

            set AppleScript's text item delimiters to oldTIDs

            end if

            end tell

          end tell

          • 2. Re: relink … {look for broken links in this folder: true}
            DBLjan Level 2

            Thank you, but I cylce thru 200-400 links, and for each link i "scan" the file path and do various searches onto that string and change it to specific folders, so handling 300 links is kinda slow. But if InDesign could look in every relinked folder for more matches, i could save up 150 links.

             

            Look at my screenshot below. This broken link would handle in a single click, but with scripting i have to cycle thru all my links.

            Also this file is merged together in a folder with many logos, if InD would "look for matching broken links in this folder" it would find 100-ish matches.

             

            But if i cant script that – thats a pity…maybe someone else has any ideas how to achiv this with ease.

             

            Bildschirmfoto 2015-06-02 um 08.04.24.png

            • 3. Re: relink … {look for broken links in this folder: true}
              AS Scripter Level 1

              Shirley Hopkins would know. I noticed she posted an answer to a different question today, so maybe she will offer a definitive answer here.

               

              ps I just had a thought: another possibility is the invoke menu action command.

              • 4. Re: relink … {look for broken links in this folder: true}
                DBLjan Level 2

                Actually theres no way to script a selection there, neither there is a menu action doing this.

                • 5. Re: relink … {look for broken links in this folder: true}
                  Laubender Adobe Community Professional & MVP

                  Hi Jan,

                  I can confirm this. Just checked all available menu actions in InDesign.

                   

                  But we could try a different strategy (not tested, just an idea):

                   

                  1. Just relink one image in the document.

                  2. Save the document.

                  3. Open the document.

                   

                  And by opening the document we have the chance to relink all missing images by a different preference one can set by scripting:

                   

                  findMissingLinksAtOpen

                   

                  in the LinkingPreferences of the app.

                   

                  Maybe that will help?

                   

                  Uwe

                  • 6. Re: relink … {look for broken links in this folder: true}
                    Laubender Adobe Community Professional & MVP

                    To expand my idea:

                     

                    1. Store all unique path names of all linked images in an associative array

                    2. Use that array to check and relink the first occassions of these images found in the links collection

                    3. Save the document

                    4. Close the document

                    5. Open the document with the preference findMissingLinksAtOpen set to true

                    6. Save the document

                    Uwe

                    • 7. Re: relink … {look for broken links in this folder: true}
                      DBLjan Level 2

                      Bildschirmfoto 2015-06-03 um 09.04.40.png

                      Its a good attemp, but these docs aren't as fast to open/close.

                      I found an javascript from Kasyan Servetsky, i'm boggeling around to understand JS but I cant.
                      What I read so far, is that he checks for multiple links by checking paths and counting, and then process theses links differently.

                      I have no time on my hands today, but I will try to mimic that in AS tomorrow…if i understand what he's doing (in JS)

                      • 8. Re: relink … {look for broken links in this folder: true}
                        Laubender Adobe Community Professional & MVP

                        Hi Jan,

                        if my basic idea works out, you "only" have to open one particular document two times.

                        And maybe there is a chance to open documents more quickly as you are doing it right now.

                        There are some document and app preferences we can put to use here. Mainly in the area of showing/or not showing the image preview proxies.
                        Also showing only greeked text.

                         

                        Even not showing the frame of an opened document.

                        This is an argument in open() method for documents.

                         

                        Btw. I can only assist with ExtendScript (JavaScript) script snippets here, because my practical knowledge of AppleScript is only rudimentary.

                         

                        Uwe