Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Inserting photo credits

Return to Member Forum

  • Author
    Posts
    • #89675

      Hi.

      I have some pictures in each page of the magazine and in each page, a box with credits for them. It’s not a problem to fill manually, but I made a script to help me and wnat to share with you all, just in case you need it too. Please don’t mind my lack of experience is scripting, I did the best I could based in scripts I found and a lot of time testing and correcting errors. ;)

      It’s very easy to use: you select a text frame you want to fill with credits and it will take the folder name of each image on the page (I receive images divided in folders for each photographer). It will take the folder name and include in the box, will ignore repeated names and will put “photos: ” or “photo:” in the beginning. Between the last two items, will put ” and ” instead of a comma.

      Hope you like. If you have any suggestions, please feel free. :)

      Luiz

      —–

      set MyArray to {}
      tell application “Adobe InDesign CC 2015”

      tell active document
      set mgItemTypes to {rectangle, oval, polygon}
      # — You need to select the text box you want to fill with credits
      set pName to name of parent page of selection
      set mgPage to page pName

      # — check if images are not in groups
      set mgGroups to (every page item of mgPage whose class is group)
      set mgItems to (every rectangle of mgPage)

      try
      repeat with x from 1 to count of mgGroups
      set mgGroupedItems to (every page item of (item x of mgGroups) whose class is in mgItemTypes)
      repeat with z from 1 to count mgGroupedItems
      set end of mgItems to item z of mgGroupedItems
      end repeat
      end repeat
      end try

      # —- start checking all items on the page
      repeat with mgCountItems from 1 to (count mgItems)
      set mgPageItem to (item mgCountItems of mgItems)
      set mgLinkName to “”
      try
      set imagepath to file path of item link of image 1 of mgPageItem as string
      set text item delimiters of AppleScript to “:”

      # —- next line will select the folder name where the image is. I kept “-2 to -2” instead of just “-2” just in case you need to change for a longer part of the path
      set ImgFolder to (text items -2 thru -2 of imagepath as string)

      on error
      set mgCountItems to mgCountItems + 1
      end try

      # ——— It’s time to make the string to be used

      set AppleScript’s text item delimiters to “, ”
      #if mgLinkName is not in MyArray then set end of MyArray to mgLinkName

      set mgLinkName to ImgFolder
      if mgLinkName is not in MyArray then set end of MyArray to mgLinkName

      end repeat

      if mgLinkName is not “” then

      set numItems to count MyArray
      set Menos to numItems – 1

      set lastItem to item numItems of MyArray

      # — set the variable to be used in the beginning of the string
      set Fotos to “Photo: ”

      if numItems > 1 then
      set Fotos to “Photos: ”
      set Pen to item Menos of MyArray
      # — here it defines that between the last two elements it will put an “and” instead of a comma
      set item Menos of MyArray to Pen & ” and ” & lastItem
      set item 1 of MyArray to Fotos & item 1 of MyArray
      set contents of selection to items 1 thru -2 of MyArray as string
      end if

      if numItems = 1 then
      # — here it sets the beginning of this array to use “photos” or “photo”, depending on the number of items.
      set item 1 of MyArray to Fotos & item 1 of MyArray
      set contents of selection to MyArray as string
      end if

      end if

      end tell
      end tell

Viewing 0 reply threads
  • You must be logged in to reply to this topic.
Forum Ads