Sed 删除“;抄袭-使用applescript从photoshop中的图层中提取文本

Sed 删除“;抄袭-使用applescript从photoshop中的图层中提取文本,sed,applescript,photoshop-cs3,Sed,Applescript,Photoshop Cs3,我可以替换当前文档中每一层的名称,但是当我通过“where name end with”时,它失败了&异常不会给出任何有价值的反馈 tell application "Adobe Photoshop CS3" tell current document set name of every layer where name ends with "copy*" to "replace_using_sed" end tell 结束语 你能发现错误吗?或者你知道另一种方法吗?不确定这是否能修复

我可以替换当前文档中每一层的名称,但是当我通过“where name end with”时,它失败了&异常不会给出任何有价值的反馈

tell application "Adobe Photoshop CS3"
tell current document
    set name of every layer where name ends with "copy*" to "replace_using_sed"
end tell
结束语


你能发现错误吗?或者你知道另一种方法吗?

不确定这是否能修复整个脚本,但它被称为“谁的”过滤器。。。因此,将“where”替换为“which”。我不是说谁的过滤器可以与photoshop一起工作,但你可以试试。如果它不起作用,那么您必须获取所有层,通过重复循环遍历它们,并逐个过滤每个名称。

复制*导致错误。不能在AppleScript中将
*
用作通配符。相反,请使用
。。。其中名称包含“复制”…

以下是我的脚本工作版本(使用Photoshop CS5测试):


不幸的是,这在CS3中不起作用。例外情况仍然很模糊,因此没有帮助。但是如果你的代码片段在CS5上运行,你可能已经帮助了很多人。真讨厌这个!划破它!我重新启动了脚本编辑器和photoshop。现在它起作用了。仍然需要一些调整来处理层集,但这是一个非常好的开始。非常感谢。
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