I am getting a stack overflow error while trying to set the label of a zipped file my script has created. Can someone advise? Thank you.
try
tell application "Finder"
set zippedFile to POSIX file (currentUserDesktopPOSIX & todayTime & ".zip") as file
set label index of zippedFile to 2
end tell
--write_error_log("successfully changed the .zip file red")
on error errMsg number errNo
display alert "I'm sorry, an error occurred while changing the color of the folder " & todayTime & "." & return & return & errMsg & return & errNo
return
end try
don’t use as file in a Finder tell block.
An AppleScript file and a Finder file (specifier) are different things.
It’s much easier to use a HFS path instead of POSIX > POSIX file > alias (or text)
As “currentUserDesktop” is the root folder of the Finder, this is suffiicient
try
tell application "Finder"
set zippedFile to file (todayTime & ".zip")
set label index of zippedFile to 2
end tell
--write_error_log("successfully changed the .zip file red")
on error errMsg number errNo
display alert "I'm sorry, an error occurred while changing the color of the folder " & todayTime & "." & return & return & errMsg & return & errNo
return
end try