Well i was looking around on the web for an applescript that would move files into separate folders when they were added to the folder.
i found a script on macosxhints but i wanted to modify it to move the files extensions not associated with any folder to be put in the “Other” folder
right now i have it set up very weirdly.
right now if i were to drop in a pdf it would copy it to the other folder then instantly copy it to the pdf folder. there has to be a better way to do this.
Thanks,
joe
property image_extension_list : {"tif", "tiff", "gif", "png", "pict", "pct", "jpg", "bmp", "psd"}
property media_extension_list : {"mp3", "avi", "mov", "mpg", "ram", "m4v", "wav"}
property archive_extension_list : {"zip", "sit", "sitx", "dmg", "tar", "hqx", "toast", "bin", "gz", "img", "iso", "tgz"}
property html_extension_list : {"js", "htm", "html"}
property text_extension_list : {"doc", "txt", "rtf"}
property pdf_extension_list : {"pdf"}
property script_extension_list : {"scpt"}
property app_extension_list : {"app"}
property image_foldername : "Images"
property media_foldername : "Media"
property archive_foldername : "Archives"
property text_foldername : "Text"
property html_foldername : "Html"
property pdf_foldername : "Pdf"
property script_foldername : "Script"
property app_foldername : "Apps"
property other_foldername : "Other"
on adding folder items to this_folder after receiving added_items
try
repeat with this_item in added_items
tell application "Finder"
if (the name extension of the this_item is not (image_extension_list is not (media_extension_list is not (archive_extension_list is not (html_extension_list is not (text_extension_list is not (pdf_extension_list is not (script_extension_list is not app_extension_list)))))))) then
my makeamove(this_item, this_folder, other_foldername)
end if
if (the name extension of the this_item is in the app_extension_list) then
my makeamove(this_item, this_folder, app_foldername)
end if
if (the name extension of the this_item is in the image_extension_list) then
my makeamove(this_item, this_folder, image_foldername)
end if
if (the name extension of the this_item is in the script_extension_list) then
my makeamove(this_item, this_folder, script_foldername)
end if
if (the name extension of the this_item is in the media_extension_list) then
my makeamove(this_item, this_folder, media_foldername)
end if
if (the name extension of the this_item is in the archive_extension_list) then
my makeamove(this_item, this_folder, archive_foldername)
end if
if (the name extension of the this_item is in the text_extension_list) then
my makeamove(this_item, this_folder, text_foldername)
end if
if (the name extension of the this_item is in the html_extension_list) then
my makeamove(this_item, this_folder, html_foldername)
end if
if (the name extension of the this_item is in the pdf_extension_list) then
my makeamove(this_item, this_folder, pdf_foldername)
end if
end tell
end repeat
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end adding folder items to
on makeamove(this_item, root_folder, target_foldername)
tell application "Finder"
if not (exists folder target_foldername of root_folder) then
make new folder at root_folder with properties {name:target_foldername}
end if
set the target_folder to folder target_foldername of root_folder
my resolve_conflicts(this_item, root_folder, target_folder)
move file this_item to the target_folder
--
end tell
end makeamove
on resolve_conflicts(this_item, root_folder, target_folder) --renames the item if dublicate exists in target folder
tell application "Finder"
set file_extension to the name extension of this_item
set the file_name to the name of this_item
if the file_extension is "" then
set the trimmed_name to the file_name
else
set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
end if
if (exists document file file_name of target_folder) then
set the name_increment to 1
repeat
set the new_name to (the trimmed_name & "_" & (name_increment as string) & "." & file_extension) as string
if not (exists document file new_name of the target_folder) then
set the name of document file file_name of folder root_folder to the new_name
exit repeat
else
set the name_increment to the name_increment + 1
end if
end repeat
end if
end tell
return the file_name
end resolve_conflicts