Applescript复制并重命名

时间:2019-05-20 15:19:29

标签: duplicates applescript rename

我正在尝试创建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

1 个答案:

答案 0 :(得分:1)

  • 首先,所有HFS路径始终以磁盘名称开头,而不以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命令一起使用。