如果您想在保存时使用原始文件名,您可以从文件的属性中将其拉出并将其与您要保存到的路径结合起来,如下所示:
set origName to the name of document 1 as string
save document 1 to ("your:path:here:" & origName)
编辑:如果您已经有自己的替换后缀的例程,则可以origName
在将其传递给 save 命令之前执行这些操作。我会在下面留下我的后缀替换,以防它对任何人都有帮助。
至于你问题的第二部分,关于替换后缀,这取决于你到底想做什么。从你的例子我猜你想增加一个数字,你可以用下面的代码来做:
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
这需要将文件的名称与其扩展名分开,通过将该名称的最后一个字符(强制为数字)增加 1 来创建一个新后缀,然后组合该批次以形成一个完整的文件名,然后您可以在保存中使用命令。
关键是拆分原始文件名,然后对部分执行操作。
现在,这目前有一些限制:除了单个数字之外的任何后缀都会使事情变得更加复杂(尽管并非不可能),并且假设运行脚本的任何人都在 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
如果您可以提供有关您打算使用的后缀的更多信息,我很乐意更新我的答案。