Hi,
I’m trying to write a folder action script to automatically move all .dmg files to a folder called “Downloads” in my user folder, but it isn’t working. Here’s what I tried:
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
activate
set downloadsFolder to "" & (path to "cusr") & "Downloads:"
if the added_items contains ".dmg" then
move the added_items to downloadsFolder
end if
end tell
end try
end adding folder items to
What seems to be the problem here? When I download files to my desktop, absolutely nothing seems to happen.
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
activate
set downloadsFolder to "" & (path to "cusr") & "Downloads:"
repeat with item_ in added_items
if name of item_ contains ".dmg" then
move item_ to folder downloadsFolder
end if
end repeat
end tell
end try
end adding folder items to
I just tested the script on my machine and it works. Enter general troubleshooting mode:
Are folder actions enabled? Do you have other folder actions that work? Are you sure that the folder action script is attached to the correct folder? Are you sure that the script is generating the correct path to the download folder?
Please don’t be offended by these questions if they seem too simple. It’s sometimes the simple things that are overlooked.
Here’s a slightly modified version that will present an error dialog if the script errors during execution.
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
activate
set downloadsFolder to "" & (path to "cusr") & "Downloads:"
repeat with item_ in added_items
if name of item_ contains ".dmg" then
move item_ to folder downloadsFolder
end if
end repeat
end tell
on error errMsg
display dialog errMsg
end try
end adding folder items to