Removing "copy #"-text from layers in photoshop using applescript
I am able to replace the name of every layer of the current document, but when I pass it "where name ends with" it fails & the exception does not give any 开发者_如何学Govaluable feedback.
tell application "Adobe Photoshop CS3"
tell current document
set name of every layer where name ends with "copy*" to "replace_using_sed"
end tell
end tell
Can you spot the error or perhaps you know an alternative way about this?
The copy*
is causing the error. You can't use *
as wildcard in AppleScript. Instead, use ... where name contains "copy" ...
.
Here's my working version of your script (tested with Photoshop CS5):
tell application "Adobe Photoshop CS3"
set layerList to name of every layer in current document where name contains "copy"
end tell
repeat with currentName in layerList
set layerName to text 1 thru ((offset of "copy" in currentName) - 1) of currentName
tell application "Adobe Photoshop CS3"
set (the name of first layer in current document where name contains "copy") to layerName
end tell
end repeat
Not sure if this will fix the whole script, but it's called a "whose" filter... so replace the word "where" with "whose". I'm not saying a whose filter works with photoshop, but you can try. If it doesn't work then you have to get all of the layers, loop through them with a repeat loop, and filter each name one-by-one.
精彩评论