1

我正在尝试设置脚本以将模板文件复制到新创建的文件夹中。该文件是从 template_name 创建的变量。不幸的是,我是 posix 新手,似乎无法让脚本将模板文件复制到新文件夹。

返回的错误是“无法将应用程序“Finder”的“/Volumes/Media/NewFolder”设置为应用程序“Finder”的文件“Volumes/Media/+A3Temp.ptx”

set temp_name to client_code & " " & brand_name & " " & job_name & " " & job_number & " " & creation_date
set media_folder to "/Volumes/Media/"
set new_folder to media_folder & temp_name
set template_name to ("+" & suite & "Temp.ptx") as string
set session_name to (client_code & " " & brand_name & " " & job_name & " " &     creation_date & ".ptx")
set template to (media_folder & template_name)



tell application "Finder"
    duplicate POSIX file template to POSIX file new_folder
end tell

我知道错误在于这些行

tell application "Finder"
    duplicate POSIX file template to POSIX file new_folder
end tell

但我不知道如何补救。有人可以帮忙吗!?

4

1 回答 1

5

运行此脚本时出现类似错误:

set f to "/usr/share/dict/connectives"
set d to "/private/tmp/"
tell application "Finder"
    duplicate POSIX file f to POSIX file d
end tell

Finder 出现错误:无法将 POSIX 文件“/private/tmp/”设置为 POSIX 文件“/usr/share/dict/connectives”。

这些中的任何一个都有效:

set f to POSIX file "/usr/share/dict/connectives"
set d to POSIX file "/private/tmp/"
tell application "Finder"
    duplicate f to d
end tell
tell application "Finder"
    duplicate POSIX file "/usr/share/dict/connectives" to POSIX file "/private/tmp/"
end tell
于 2013-07-05T13:30:14.043 回答