can someone diagnose why the name the dropped file will not change, nor will it generate an error providing me a dialog.
on adding folder items to this_folder after receiving added_items
try
repeat with anItem in added_items
set prefix to (time of (current date))
tell application "Finder"
set oldName to name of anItem
set newName to (prefix & "_" & oldName)
end tell
set name of anItem to newName
end repeat
on error
display dialog "a;lkdjfa;dlkjfl;aj!"
end try
end adding folder items to
must be within the Finder tell block.
But you will run into another problem: Renaming a file in a hot folder will retrigger the folder action, and so on, and so on.
I’m not sure why the folder action wouldn’t throw an error, but I see two errors.
First is that when you setName you actually ending up with a list because your mixing data types. The second issue is that you are changing names outside of the Finder block which won’t work anyways.
SO taking those two fixes and cleaning up the code (limiting it to only one Finder call, and only calling the time call once) I’m left with this.
on adding folder items to this_folder after receiving added_items
set prefix to (time of (current date))
tell application "Finder"
repeat with anItem in added_items
set oldName to name of anItem
set newName to (prefix & "_" & oldName) as Unicode text
set name of anItem to newName
end repeat
end tell
end adding folder items to