如果你想使用保存在原來的文件名,你可以從文件的屬性把它和與路徑結合起來,你要保存到,像這樣:
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
如果你能提供有關你要使用的後綴一些更多的信息我很高興來更新我的答案。