This script should examine every rectangle in an InDesign document, then put a text frame in the upper left corner with the name of the graphic and the scale percentage it is used at. I already have “C=0 M=0 Y=100 K=0” as a swatch color.
This works sometimes, but I am stuck trying to debug this:
tell application "Adobe InDesign CS3"
set frames to ""
set myWindow to active window
activate
if (document 1 exists) then
tell document 1
tell myWindow
set zoom percentage to 100
end tell
set AppleScript's text item delimiters to ":"
repeat with p from 1 to count of pages
tell page p
repeat with i from 1 to count of rectangles
set filePath to (file path of item link of graphic 1 of rectangle i) as Unicode text
if filePath is not "null" and filePath is not "no disk file" then -- not tested
set fileName to text item -1 of filePath
tell rectangle i
set {sc1, sc2} to {horizontal scale, vertical scale}
set {x1, y1} to items 1 thru 2 of geometric bounds
set y2 to ((y1 as real) + 3)
set x2 to ((x1 as real) + 0.25)
end tell
set newTextFrame to make text frame at beginning with properties {geometric bounds:{x1, y1, x2, y2}}
tell newTextFrame
set fill color to "C=0 M=0 Y=100 K=0"
set label to "annotate" & i
set text 1 to ("" & fileName & " " & (sc1 as text))
set applied font of text 1 to "Monaco"
set point size of text 1 to 11
end tell
end if
end repeat --frames
end tell
end repeat --pages
set AppleScript's text item delimiters to {""}
end tell
display dialog "Done." buttons "OK" default button 1 with icon 1 giving up after 1
else
display dialog "Open a document, please." buttons "OK" default button 1 with icon 2
end if
end tell
It stops at
set filePath to (file path of item link of graphic 1 of rectangle i) as Unicode text
Why? Any help would be appreciated.