Applescript / Indesign: Add script label to Inline Graphic


I currently have a document containing 1000’s of inline .eps icons that I want to tag with a script label depending on which icon is found.

So far I have the following that doesn’t work.

tell application "Adobe InDesign CC 2015"
	tell document 1

repeat with target in (get stories's all graphics)
			if target's link name contains "FileName1" then
				set target's parent's parent's label to "FileName1"
			end if
		end repeat
	end tell
end tell

I have this that does work but I need to test individual link names for different script tags.

tell application "Adobe InDesign CC 2015"'s document 1 to repeat with target in (get stories's all graphics) --anchored objects
	set target's parent's parent's label to "FileName1"
end repeat



just got this reply on the adobe forum.

hi Shane;

try this javascript if it work will convert the same in AppleScript.

var myDoc= app.activeDocument;
var myGraphics=myDoc.stories[0].allGraphics;;
for(var i=0 ; i < myGraphics.length ; i++)
var myName= myGraphics[i];
myGraphics[i].label = myName;


Hi, Shane. If you aren’t in the habit of doing so, you can use return in the middle of code to get a result; understanding what an object is can help you determine”via the Applescript dictionary”if you are addressing the correct object or using the right command. In this case, target contains image ids. Item link is the link reference to an image id.

[format]if target’s item link’s name contains…[/format]