I am looking for a script which will help unclutter my desktop.
I would like a folder action script which takes any new item on my desktop and pops it into subfolders depending on its file type.
I have tried
FileShuttleX but when I unarchive the file there is no script there?
Anything else to try?
Yours
Jason
Model: Mac powerbook
Browser: Safari 416.13
Operating System: Mac OS X (10.4)
The file type parameter supposedly available via Applescript is unreliable, due to that parameter NOT being written by all appllications. This thread has some more details you may find interesting.
As long as you can use file extensions to delinieate the different files, you should be able to get something to work. I have no experience with folder actions, but here is another thread that may help you get started, if you need it.
If you encounter any problems along the way, post your script up here (working or not) and you will have plenty of assistance.
set f to (choose folder with prompt “Choose folder with items:”)
tell application “Finder”
try
set item_list to (every item of f) as alias list
on error
set item_list to (first item of f) as alias as list
end try
end tell
if archive_folder is missing value then
set archive_folder to (choose folder with prompt “Choose Archive Folder:”)
end if
repeat with this_item in item_list
set item_info to (info for this_item)
if package folder of item_info then
set folder_name to “Packages”
else if folder of item_info then
set folder_name to “Folders”
else if alias of item_info then
set folder_name to “Aliases”
else
set folder_name to name extension of item_info
if folder_name is missing value then
set folder_name to file type of item_info
if folder_name is “” or folder_name is missing value then
set folder_name to “File extension or file type missing”
end if
end if
end if
try
set destination_folder to (“” & archive_folder & folder_name & “:”) as alias
on error
tell application “Finder”
set destination_folder to (make new folder at archive_folder with properties ¬
{name:folder_name}) as alias
end tell
end try
tell application “Finder”
activate – optional
reveal destination_folder – optional
move this_item to destination_folder
end tell
end repeat
I think this covers all Finder elements otherwise an item should be sent to the “File extnesion of file type missing” folder.
This is easily converted to folder action script, but this can be run from the script editor for further testing. This might just get you started.
BTW, I wouldn’t move the files within the main folder where the items are dropped when you do your folder action. When the new sub folders are created, this will cause problems with the folder action, because the folder action script will think that the new folders are new items.