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

Editing script label of every text frame with AppleScript

New Here ,
Dec 30, 2019 Dec 30, 2019

Hey, I'm trying to remove a hard return I have in some of my script labels on an InDesign document, but keep getting the error. Each page has multiple layers each with a text item that contains the label.

 

 Screen Shot 2019-12-30 at 8.15.00 AM.png

 

Here's the script:

 

tell application "Adobe InDesign CC 2018"

tell document 1

set label of (every text frame whose label is "Filename

") to "Filename"

end tell

end tell

 

Thanks!

TOPICS
Scripting
1.0K
Translate
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

correct answers 1 Correct answer

Community Expert , Dec 30, 2019 Dec 30, 2019

I get the same error if there are no text frames in the document with the "Filename" & return label—it worked the first time, but not when I ran it again. I think you need to catch that error:

 

 

tell application "Adobe InDesign CC 2018"
	tell document 1
		try
			set label of (every text frame whose label is "Filename" & return) to "Filename"
		end try
	end tell
end tell

 

Translate
Community Expert ,
Dec 30, 2019 Dec 30, 2019

For writing the return character in the code type \r so the line should be 

set label of (every text frame whose label is "Filename\r") to "Filename"

 When you then execute the applescript editor does change \r to a new line but the code does work. Tested it on CC2020

 

-Manan

Translate
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 ,
Dec 30, 2019 Dec 30, 2019

I get the same error if there are no text frames in the document with the "Filename" & return label—it worked the first time, but not when I ran it again. I think you need to catch that error:

 

 

tell application "Adobe InDesign CC 2018"
	tell document 1
		try
			set label of (every text frame whose label is "Filename" & return) to "Filename"
		end try
	end tell
end tell

 

Translate
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
Participant ,
Dec 30, 2019 Dec 30, 2019

I always use "(return)" for a Carriage Return:

 

        set label of (every text frame whose label is ("Filename" & (return))) to "Filename"

 

Also, I set the label of an item after typing it by using the Enter key (not the Return key).

Translate
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 ,
Dec 30, 2019 Dec 30, 2019
LATEST

The script works with  either \r or & return, but only once—you need the try statement.

Translate
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