I made an apple script to move images into folders based on it's Year and Month. I use it to archive raw images when I'm done with it. Though it could help others out there.
Using the "Folder Actions Setup".
It will get the year and month of the file.
Create a folder and set the filename to its year, then create another folder in the year folder and set the filename to it's month and move the file into it.
property month_index : {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}
on adding folder items to this_folder after receiving these_items
#set this_year to the year of (current date)
try
tell application "Finder"
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items as alias
set item_type to the kind of this_item as string
if item_type is not "Folder" then
set file_date to the creation date of this_item
set file_year to the year of file_date as string
set j to the month of file_date as integer
set file_month to item j of month_index as string
set Done to my move_file(this_folder, file_year, file_month, this_item)
else if item_type is "Folder" then
exit repeat
end if
end repeat
end tell
on error error_message number error_number
if error_number is not -128 then
display dialog error_message & error_number buttons {"Cancel"} default button 1 giving up after 120
end if
end try
end adding folder items to
on move_file(main_folder, year_foldername, month_foldername, this_item)
try
tell application "Finder"
set year_folder to my create_folder(main_folder, year_foldername)
set month_folder to my create_folder(year_folder, month_foldername)
move this_item to the month_folder without replacing
end tell
on error error_message number error_number
if error_number is -15267 then
rename_file(month_folder, this_item)
else if error_number is not -128 then
display dialog error_message & " move file " & error_number buttons {"Cancel"} default button 1 giving up after 120
end if
end try
end move_file
on create_folder(directory, foldername)
try
tell application "Finder"
if not (exists folder foldername of directory) then
make new folder of directory with properties {name:foldername}
end if
set the sub_folder to (folder foldername of directory) as alias
return sub_folder
end tell
on error error_message number error_number
if error_number is not -128 then
display dialog error_message & " create_folder " & error_number buttons {"Cancel"} default button 1 giving up after 120
end if
end try
end create_folder
on rename_file(sub_folder, this_item)
try
tell application "Finder"
set increment to 1
set file_name to the name of this_item
set file_extension to the name extension of this_item
set old_file to the (file (name of this_item) of folder sub_folder) as alias
repeat
set trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
set new_name to (the trimmed_name & " " & (increment as string) & "." & file_extension) as string
if not (exists document file new_name of the sub_folder) then
set name of (document file file_name of sub_folder) to the new_name
move document file this_item to the sub_folder
exit repeat
else
set the increment to the increment + 1
end if
end repeat
end tell
on error error_message number error_number
if error_number is not -128 then
display dialog error_message & " archive_file " & error_number buttons {"Cancel"} default button 1 giving up after 120
end if
end try
end rename_file
0
0
26