I'm very new to writing applescript, but have been painfully working through it.
I have successfully written scripts to download specific csv attachments from an email inbox, then create an SQL insert statement from them. I'm now trying add a statement to move the original file to an archive folder so the SQL insert script does not act on those files the next time it runs. The variable"DEP_name" is the name of the file captured earlier in the script:
tell application "Finder"
set orgpath to "Macintosh HD:Users:me:Documents:source_folder:" as string
set originalFolder to (orgpath & DEP_name) as string
set newpath to "Macintosh HD:Users:me:Documents:Archive:" as string
set newFolder to (newpath & DEP_name) as string
move originalFolder to newFolder with replacing
end tell
With this version I get the error: "Finder got an error: AppleEvent handler failed." I have also tried using the Posix file path, but I am getting a different error with that attempt. Any help would be appreciated.
Best Answer
Change the second to last line to:
There are two things:
All four variables are just strings. In order to tell Finder that they are related to the filesystem, add
alias
(orfile
orfolder
) before the string.The path where are are moving it to should be the path of the enclosing folder, not the path of the moved folder in its new location.