Applescript 复制和重命名

Applescript to duplicate and rename

我正在尝试创建 AppleScript 以在重命名文件时将单个文件复制到新位置。我在重命名文件时挂断了电话。

我试过设置"with properties"、设置别名,但仍然出现错误。

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
  • 首先,所有 HFS 路径始终以磁盘名称开头,绝不会以 Volumes.
  • 其次永远不要将 file 关键字放在 alias 说明符前面

使用 Finder 需要两个步骤:复制文件然后重命名。
利用 duplicate 的 return 值,这是重复的文件。

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 命令。