Michael Powell
Michael Powell

Reputation: 31

Applescript Posix files and paths

I am trying to set a script to duplicate a template file to a newly created folder. The file is a variable created from template_name. Unfortunately I am a posix novice and can't seem to get the script to copy the template file to the new folder.

The returned error is "Can't set "/Volumes/Media/NewFolder" of application "Finder" to file "Volumes/Media/+A3Temp.ptx" of application "Finder"

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

I know the error is with these lines

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

But i have no clue as how to remedy it. Can anyone help please!?

Upvotes: 1

Views: 1620

Answers (1)

Lri
Lri

Reputation: 27633

I got a similar error when I ran this script:

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 got an error: Can’t set POSIX file "/private/tmp/" to POSIX file "/usr/share/dict/connectives".

Either of these worked though:

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

Upvotes: 5

Related Questions