1 Reply Latest reply on Jun 27, 2013 9:21 PM by Janaaaaa

    applescript -get filename make hyperlink

    Janaaaaa

      hi. Thsi script is not working. It wont get 7 first digits of filename and

      when making hyperlinks to image(link) i got error. Is thre anyone who can help?

       

       

      tell application "Adobe InDesign CS5.5"

         

          tell the active document

              set AllmyLinks to every link

              repeat with i in AllmyLinks

                  set FilePath to file path of i as string

                 

      -- get first 7 character of filename

                  tell application "Finder"

                      activate

                      reveal FilePath

                     

                      set OldName to selection as alias

                      set NewName to (characters 1 thru 7 of (OldName as text)) as text

                --  display dialog NewName -- returns untitled??

                  end tell

                 

                 

        --make hyperlink

                  if not (exists hyperlink URL destination NewName) then

                      set TheH to make hyperlink URL destination with properties {name:NewName, destination URL:NewName}

                  else

                      set TheH to hyperlink URL destination NewName

                  end if

                 

                 

                 

                  set TheHSName to NewName

                  set TheHS to make hyperlink text source with properties {name:TheHSName, source text:(item i of AllmyLinks), hidden:false}

                  -- source text item i of AllmyLinks is not working?

       

                  make new hyperlink with properties {destination:TheH, source:TheHS, visible:false, highlight:invert}

                

              end repeat

          end tell

      end tell

        • 1. Re: applescript -get filename make hyperlink
          Janaaaaa Level 1

          And now I got  this one working.

          One think was that I changed hyperlink text item source to hyperlink page item source

           

          Not the best and most robust script but it servers my purpose.

           

          You have to select images with white arrow,and run script.

           

           

          thanks for looking.

           

           

           

           

          tell application "Adobe InDesign CS5.5"

                    set user interaction level of script preferences to interact with all

                    tell the active document

           

           

           

           

           

                              set the_selection to selection -- Returns a list     

                              repeat with newselection in the_selection

                                        set the_graphic to item 1 of newselection

                                        set the_graphics_link to item link of the_graphic

                                        set FilePath to file path of the_graphics_link

           

           

           

           

           

           

                                        tell application "Finder"

            activate

            reveal FilePath

                                                  delay 3

                                                  set fileAlias to the selection as alias

                                                  set OldName to name of fileAlias

                                                  set NewName to characters 1 thru 7 of OldName as text

           

                                        end tell

           

           

           

           

           

            --make hyperlink

                                        if not (exists hyperlink URL destination NewName) then

                                                  set TheH to make hyperlink URL destination with properties {name:NewName, destination URL:NewName}

                                        else

                                                  set TheH to hyperlink URL destination NewName

                                        end if

           

           

           

                                        set TheHSName to NewName

                                        set TheHS to make hyperlink page item source with properties {name:TheHSName, source page item:the_graphic, hidden:false}

           

            make new hyperlink with properties {destination:TheH, source:TheHS, visible:false, highlight:invert}

           

           

           

                              end repeat

                    end tell

          end tell