我正在尝试创建一个 AppleScript 以在重命名文件时将单个文件复制到新位置。我对文件的重命名感到困惑。
我尝试过设置“使用属性”、设置别名,但仍然出现错误。
tell application "Finder"
set JobName to text returned of (display dialog "Please Enter Crate Name:" default answer "Job_Name")
set loc to alias "Volumes:MusicExt:_Serato_:Subcrates:"
set templatefile to alias "Volumes:MusicExt:Serato_Working:crate-template.crate"
duplicate file templatefile to loc --> with properies {name:JobName}
duplicate file templatefile to loc --> with properies {name:"10. Pre-CMY.m3u"}
end tell
Volumes
开头。file
关键字放在 alias
说明符前面使用 Finder,您需要两个步骤:复制文件,然后重命名。
利用
duplicate
的返回值,即重复的文件。
tell application "Finder"
set JobName to text returned of (display dialog "Please Enter Crate Name:" default answer "Job_Name")
-- In this case just HFS string paths are preferable
set loc to "MusicExt:_Serato_:Subcrates:"
set templatefile to "MusicExt:Serato_Working:crate-template.crate"
set duplicatedFile to duplicate file templatefile to folder loc
set name of duplicatedFile to JobName -- (& ".crate") is there no file extension??
end tell
注意:
with properties
仅适用于 make
命令。
是否可以修改此脚本,以便它提示我为顶级文件夹输入新名称?
我为什么需要这个?因为有时我需要在同一目录中复制文件夹树。就目前情况而言,如果我尝试将其保存到同一目录中,则会引发错误。
蒂亚!