6 Replies Latest reply on Aug 14, 2012 4:00 PM by bt4design

    Indesign CS5.5 Relink Script needs help

    bt4design

      Hi, I'm trying to relink images in an InDesign CS5.5 file to a different server using a script. This is what I have so far, but when I run the script I get errors and can't relink because "Either the file does not exist, you do not have permission, or the file may be in use by another application". Does anyone know how to make this script work? I'm fairly new to scripting.

       

      Here is the script I have:

       

      tell application "Adobe InDesign CS5.5"

                tell document 1

                          set linkList to links

                          set errInfo to "" -- We'll display error if we can't relink an item

        -------

                          repeat with x in linkList

                                    if (x's status) is not normal then -- I usually check for any link that has an error

        -- This should only return an AppleScript path with ":" separators

                                              set linkPath to (x's file path) as string

        -------

                                              if "Volumes/Calendars_2013 FPO" is in linkPath then

                                                        set AppleScript's text item delimiters to "Volumes/Calendars_2013 FPO"

                                                        set linkPath to (linkPath's text items) -- Create a list of text items

                                                        set AppleScript's text item delimiters to "Volumes/Calendars_2013"

                                                        set linkPath to (linkPath as string) -- Concatenate with new path

                                                        set AppleScript's text item delimiters to "" -- Reset TIDs

        -------

                                                        try

        -- Need to make our string (path) into an alias path

        relink x to alias linkPath

        -------

                                                                  try

        update x -- This can be helpful

                                                                  end try

                                                        on error err

        -- We'll store link name if error occurs

                                                                  set errInfo to (errInfo & return & x's name)

                                                        end try

                                              end if

                                    end if

                          end repeat

        -------

        -- If an error occurs while trying to relink, we'll display it

                          if (count errInfo) > 0 then display dialog ("Can't relink:" & errInfo)

                end tell

      end tell

       

       

      --Hector


        • 1. Re: Indesign CS5.5 Relink Script needs help
          -hans- Level 4

          Hi,

           

          'Volumes/...' is a posix path. file path on a mac returns hfs path. try hfs: "Calendars_2013 FPO:" instead of posix: "Volumes/Calendars_2013 FPO"

          • 2. Re: Indesign CS5.5 Relink Script needs help
            bt4design Level 1

            I just tried adding collens to the end of the folder path. For some reason the script skipped the relink line. Below is the code with your update. I'm thinking its not finding the images because the script needs to make a list of all the images and choose the one that matches the missing image.

             

            tell application "Adobe InDesign CS5.5"

                      tell document 1

                                set linkList to links

                                set errInfo to "" -- We'll display error if we can't relink an item

              -------

                                repeat with x in linkList

                                          if (x's status) is not normal then -- I usually check for any link that has an error

              -- This should only return an AppleScript path with ":" separators

                                                    set linkPath to (x's file path) as string

              -------

                                                    if "Calendars_2013 FPO:" is in linkPath then

                                                              set AppleScript's text item delimiters to "Calendars_2013 FPO:"

                                                              set linkPath to (linkPath's text items) -- Create a list of text items

                                                              set AppleScript's text item delimiters to "Calendars_2013:"

                                                              set linkPath to (linkPath as string) -- Concatenate with new path

                                                              set AppleScript's text item delimiters to "" -- Reset TIDs

              -------

                                                              try

              -- Need to make our string (path) into an alias path

              relink x to alias linkPath

              -------

                                                                        try

              update x -- This can be helpful

                                                                        end try

                                                              on error err

              -- We'll store link name if error occurs

                                                                        set errInfo to (errInfo & return & x's name)

                                                              end try

                                                    end if

                                          end if

                                end repeat

              -------

              -- If an error occurs while trying to relink, we'll display it

                                if (count errInfo) > 0 then display dialog ("Can't relink:" & errInfo)

                      end tell

            end tell

             

            --Thanks for you help

            • 3. Re: Indesign CS5.5 Relink Script needs help
              -hans- Level 4

              Hi,

               

              just checked the script and it works properly.

              this line ' if (x's status) is not normal then' stopps any relinking if the status of the link is normal.

              perhaps here's the reason / missunderstanding for you to say the script skips ....

              so what do you want to do¿

              relink the links whose status is equal to normal? then change the line to 'if (x's status) is  normal then' ... ;-)

              • 4. Re: Indesign CS5.5 Relink Script needs help
                bt4design Level 1

                Hello,

                 

                I just tried the script I last posted. This is the result I receive when I run the script:

                 

                get status of link id 75673 of image id 74442 of rectangle id 74441 of spread id 45573 of document id 25

                  --> link missing

                          get file path of link id 75673 of image id 74442 of rectangle id 74441 of spread id 45573 of document id 25

                                    --> "/Volumes/Calendars_2013 FPO/2013_Dog_Breeds/2013_A_B/9764-2_BichonPups_SQ/9764-2_imagefolder_SQ2013/9764-2_01a_SQ 2013.jpg"

                end tell


                --What I want the script to do is for the link that is missing to be relinked to the new location 'Calendar_2013'. I'm not sure why it's skipping this step in the script:

                try

                  -- Need to make our string (path) into an alias path

                  relink x to alias linkPath

                  -------

                                                                            try

                 

                --thanks again

                • 5. Re: Indesign CS5.5 Relink Script needs help
                  -hans- Level 4

                  hi,

                   

                  whatever ... the dictionary says ...

                                      --> "/Volumes/Calendars_2013 FPO/2013_Dog_Breeds/2013_A_B/9764-2_BichonPups_SQ/9764-2_imagefolder_ SQ2013/9764-2_01a_SQ2013.jpg"

                   

                  this is no macPath.

                   

                  so let's try the text item delimiters from you first post and:

                   

                    relink x to posix file linkPath

                   

                  Hope it'll work