Apple脚本:将文件复制到生成的文件夹

时间:2013-04-29 10:31:14

标签: applescript duplicates

我想运行一个脚本,将模板文件“+ A3Temp.ptx”复制到内部媒体驱动器上的脚本生成文件夹中。 job_number&的变量creation_date& client_folder& brand_name&先前已在脚本中输入job_name

这就是我所拥有的,但却不断返回错误:

set media_folder to "/Volumes/Media/"
set new_folder to media_folder & job_number & creation_date & client_folder & brand_name & job_name
set destination_folder to quoted form of POSIX path of new_folder

tell application "Finder"
    duplicate POSIX file "/Volumes/Media/+A3Temp.ptx" to folder destination_folder
end tell

如你所见,我是新手,需要帮助。

所有帮助感谢,谢谢。

2 个答案:

答案 0 :(得分:0)

我认为(因为我也是新手)你需要将new_folders设置为列表,例如 set newFolder to {job_number, creation_date, media_folder, client_folder, brand_name} -- newFolders list。现在set every folder of destinationFolder to quoted form of POSIX path of new_folder。不完全确定,但这可能会解决您的问题。

你的脚本的其余部分看起来不错。

答案 1 :(得分:0)

使用POSIX file将路径转换为文件对象:

tell application "Finder"
    duplicate POSIX file "/usr/share/doc/bash/bashref.html" to POSIX file "/private/tmp/"
end tell

POSIX path of将文件对象或别名转换为路径。

quoted form of转义字符串以用于shell。它用单引号括起文本,并用'\''替换单引号,例如quoted form of "it's"'it'\''s'