1

I am writing a scipt to create user folders and copy relevant applications templates to the main folder on an external media volume. Earlier user-entered information is provided through a dialog box. The +A3Temp.ptx file has been duplicated to the new_folder, now I wish to rename the "+A3Temp.ptx" file to a format which uses CreationDate_ClientFolder_BrandName_JobName as its.ptx as the filename.

This is what I have so far, yet the final stage still returns class errors.

set temp_name to job_number & creation_date & client_folder & brand_name & job_name
set media_folder to "/Volumes/Media/"
set new_folder to media_folder & temp_name
set template_name to "+A3Temp.ptx"
set session_name to (creation_date & client_folder & brand_name & job_name & ".ptx")

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

tell application "Finder"
    set name of POSIX file (new_folder & "/" & template_name) to POSIX file (new_folder & "/" & session_name)
end tell

The errors come back as :

"Can't set <<class psxf>> "Volumes/Media/1223456_130430_clientfolder_BrandName_JobName/+A3Temp.ptx of application "Finder" to <<class psxf>> ""Volumes/Media/1223456_130430_clientfolder_BrandName_JobName/130430_clientfolder_BrandName_JobName.ptx" of application "Finder"

What am i doing wrong?????

4

1 回答 1

1

将文件对象转换为别名:

tell application "Finder"
    set name of (POSIX file "/tmp/a" as alias) to "b"
end tell

如果 new_folder 不存在,则不会创建副本:

tell application "Finder"
    make new folder at media_folder with properties {name:temp_folder}
end tell
于 2013-04-30T16:45:24.100 回答