Removing 1st 4 letters of layer names in Indesign CS6 (1-40 layers)

Looking to get a script to automate the removal of the word “form” from my layers of InDesign CS6. The layers are automatically pre-set. I have to remove these manually. The amount varies with data import anywhere from 1 to 40 layers. Any help would be greatly appreciated.



Try the following. It gets a list of existing layers, and then removes "form " from each (remove the trailing space if you do not need it).

tell application "Adobe InDesign CS6"
	tell document 1
		set everyLayer to every layer
		repeat with thislayer in everyLayer
			set thisLayerNewName to my replaceString(name of thislayer, "form ", "")
			set name of thislayer to thisLayerNewName
		end repeat
	end tell
end tell

on replaceString(theText, oldString, newString) -- // Handler description: replaces one delimiter for another in a string
	set AppleScript's text item delimiters to oldString
	set tempList to every text item of theText
	set AppleScript's text item delimiters to newString
	set theText to the tempList as string
	set AppleScript's text item delimiters to ""
	return theText
end replaceString

Amazing! Worked like a charm. Thank you :slight_smile: