Saturday, September 23, 2017

#1 2017-08-21 03:47:10 pm

ShirleyP
Member
Registered: 2016-10-25
Posts: 2

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

Hi,
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.

Thanks!!

Offline

 

#2 2017-08-23 08:23:04 am

IanMcP
Member
From:: Newcastle, UK
Registered: 2006-10-19
Posts: 83

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

Hi,

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

Applescript:

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

Offline

 

#3 2017-09-11 02:40:16 pm

ShirleyP
Member
Registered: 2016-10-25
Posts: 2

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

Amazing! Worked like a charm. Thank you :-)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)