我能够替换当前文档每一层的名称,但是当我将它传递到“名称以结尾的位置”时,它会失败并且异常不会提供任何有价值的反馈。
tell application "Adobe Photoshop CS3"
tell current document
set name of every layer where name ends with "copy*" to "replace_using_sed"
end tell
结束告诉
你能发现错误,或者你知道另一种方法吗?
我能够替换当前文档每一层的名称,但是当我将它传递到“名称以结尾的位置”时,它会失败并且异常不会提供任何有价值的反馈。
tell application "Adobe Photoshop CS3"
tell current document
set name of every layer where name ends with "copy*" to "replace_using_sed"
end tell
结束告诉
你能发现错误,或者你知道另一种方法吗?
不确定这是否会修复整个脚本,但它被称为“谁的”过滤器......所以用“谁”替换“哪里”这个词。我不是说谁的滤镜适用于 Photoshop,但你可以试试。如果它不起作用,那么您必须获取所有层,通过重复循环遍历它们,并逐个过滤每个名称。
copy*
导致错误。您不能*
在 AppleScript 中用作通配符。相反,使用... where name contains "copy" ...
.
这是我的脚本的工作版本(使用 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