如果你想使用保存在原来的文件名,你可以从文件的属性把它和与路径结合起来,你要保存到,像这样:
set origName to the name of document 1 as string
save document 1 to ("your:path:here:" & origName)
编辑:如果您已经有自己的例程来替换后缀,您可以在将它传递给保存命令之前,在origName
上执行这些操作。我会留下我的后缀替换下面,以防万一它有助于任何人。
至于你的问题的第二部分,关于替换后缀,这取决于你想要做什么。从你的例子我猜你想增加一个号码,你可以用下面的代码做:
set thePoint to the offset of "." in origName
set firstPart to (characters 1 through (thePoint - 1) of origName) as string
set fpLength to the length of firstPart
set newSuffix to ((the last character of firstPart) as number) + 1
set newName to (characters 1 through (fpLength - 1) of firstPart) & newSuffix ¬
& ".indd" as string
这需要从它的扩展名分隔文件名,通过增加最后一个字符创建一个新的后缀(强制为一个数字)的名称,然后将这个组合成一个完整的文件名,然后可以在save命令中使用它。
关键是拆分原始文件名,然后对零件执行操作。
现在,它目前有一些限制:除了一位数字以外的任何后缀使事情变得更加复杂(尽管不是不可能),并且假定运行该脚本的任何人在Finder的首选项中启用了“显示所有文件扩展名”这可以解决,虽然)。
结束语一切行动给了我们这样的:
tell application "Adobe InDesign CS5.5"
set origName to the name of document 1 as string
set thePoint to the offset of "." in origName
set firstPart to (characters 1 through (thePoint - 1) of origName) as string
set fpLength to the length of firstPart
set newSuffix to ((the last character of firstPart) as number) + 1
set newName to (characters 1 through (fpLength - 1) of firstPart) ¬
& newSuffix & ".indd" as string
save document 1 to ("your:path:here:" & newName)
end tell
如果你能提供有关你要使用的后缀一些更多的信息我很高兴来更新我的答案。