Two problems, first having difficulty moving or copying a file to a Burn Folder:
tell application "Finder"
if exists "Macintosh HD:Users:dougkemme:Documents:ToBurn:Images.pdf" then
move file (alias "Macintosh HD:Users:dougkemme:Documents:ToBurn:Images.pdf") to folder "Macintosh HD:Users:dougkemme:Burn Folder"
end if
end tell
gives a Finder got an error: Can’t get file (alias “Macintosh HD:Users:dougkemme:Documents:ToBurn:Images.pdf”).
I know the file exists given the if statement and I am able to move to trash without problems.
Second, once I get the file ( alias ) moved to the Burn Folder, how do I applescript the burn. I have discovered the application “Finder” will allow a burn command but unable to find in the dictionary…
You can’t just use an “if exists” to check the existence of a file or folder. Finder will return an error and your script will halt (as you see). Instead, use a try…on error clause. I use the following to test for the existence of a file (in this case ‘fileToTest’, a string with anything in it, such as “Macintosh HD:John.doc”):
try -- If this fails if the path is invalid.
alias fileToTest -- Try to get a reference to the file
-- Any code to be executed if the file exists should go here
on error
beep
display dialog fileToTest & " does not appear to exist." buttons {"OK"} default button "OK" with icon stop
end try
you don’t need tell app “finder” and ust alias referneces
Point to a file first using a try on error clause
If the file does not exests then you will get the message if it does it will move the file
set movepath to alias "Macintosh HD:Users:dougkemme:Burn Folder"
try
set p_ath to alias "Macintosh HD:Users:dougkemme:Documents:ToBurn:Images.pdf"
tell app "Finder"
move file p_ath to folder movepath
end tell
on error
beep
display dialog "File does not appear to exist." buttons {"OK"} default button "OK" with icon stop
end try
the first set will not work if the folder is a burn folder. Works great for all other folders, but not a burn folder. A little digging and I have found that these burn folders store an alias to the file to be burned, which is burning me.