Copy link to clipboard
Copied
I wrote a code as follows, but I found that it was not executed well. The error message was always: "Adobe InDesign CC 2019" encountered an error: "graphic of item 1 of every page of document id 4" did not understand the "count" information.
Can anyone tell me where the problem is?
tell application "Adobe InDesign CC 2019"
set currentDoc to active document
repeat with currentPage in pages of currentDoc
repeat with currentGraphic in (every graphic of currentPage)
if (class of currentGraphic is image) then
set theLink to (link of currentGraphic)
if (theLink is missing value) or (status of theLink is link missing) then
delete currentGraphic
end if
end if
end repeat
end repeat
end tell
Copy link to clipboard
Copied
first, use all graphics instead of every graphic
Copy link to clipboard
Copied
second, replace (link with (item link
Copy link to clipboard
Copied
Sorry, I am not very familiar with the instructions in InDesign, so I don't know how to modify what you said. Can you help me make changes in my code? Thank you very much for your help~
Copy link to clipboard
Copied
in your code, replace "every graphic" with "all graphics", and "(link" with "(item link".
you can use the find/replace facility in Script Editor (or another text editor).
Copy link to clipboard
Copied
After the modification, it can run correctly, but these boxes are not deleted. Why is this? Please help me again
Copy link to clipboard
Copied
Since you check for the image class, you need to delete parent of currentGraphic (i.e. delete rectangle), because you find rectangles that already have an image inside.
For empty frames, you should probably go through all page items, check for rectangle class, check its content type, then delete if it's empty. I'm not sure it's the best approach, it's just a general suggestion. I don't have a ready solution for this right now.
Make sure to carefully explore the InDesign dictionary in Script Editor.
Copy link to clipboard
Copied
I tried different types of boxes, but it didn't work.
Copy link to clipboard
Copied
tell application „Adobe InDesign 2025“
set currentDoc to active document
repeat with currentPage in pages of currentDoc
repeat with currentGraphic in (all graphics of currentPage)
if (class of currentGraphic is image) then
set theLink to (item link of currentGraphic)
if (theLink is missing value) or (status of theLink is link missing) then
set parentFrame to (parent of currentGraphic)
delete currentGraphic
delete parentFrame
end if
end if
end repeat
end repeat
end tell