• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using AppleScript to remove link boxes with no content

New Here ,
Nov 25, 2024 Nov 25, 2024

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

截屏2024-11-26 上午10.04.58.png

TOPICS
Scripting

Views

127

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

first, use all graphics instead of every graphic

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

second, replace (link with (item link

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2024 Nov 25, 2024

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~

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2024 Nov 26, 2024

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 26, 2024 Nov 26, 2024

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2024 Nov 27, 2024

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 29, 2024 Nov 29, 2024

Copy link to clipboard

Copied

I tried different types of boxes, but it didn't work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 02, 2024 Dec 02, 2024

Copy link to clipboard

Copied

LATEST
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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines