Now I need a script to move these files to different subdirectories YYYY-MM-DD under “Photos” based on the filename.
These subdirectories have to be created if the do not exist.
It 'aint pretty, but it seems to do what you want
cheers!!
Howard
property photos_archive : alias "hard drive name:Users:username:Desktop:photos:"
on open thefiles
repeat with thisfile in thefiles
tell application "Finder"
set pathname to thisfile as alias
set the_file_name to thisfile as string
set AppleScript's text item delimiters to "-"
set folder_name to words -8 thru -6 of the_file_name as string
if folder named folder_name in folder photos_archive exists then
move thisfile to folder folder_name of folder photos_archive replacing yes
else
set pub_date_folder to make folder in folder photos_archive
set name of pub_date_folder to folder_name
move thisfile to folder folder_name of folder photos_archive replacing yes
end if
set AppleScript's text item delimiters to ""
end tell
end repeat
end open
I’m assuming that what you want to do is have an attached folder action to automatically process jobs you stick in a folder? If so it’s pretty easy - you just have to change the first and last lines
You’ll need to save the it as a “script” into you Library/Scripts/Folder Action Scripts folder and attach it to another folder as a folder action
property photos_archive : "Macintosh HD:Users:yourusername:Desktop:photos:"
on adding folder items to this_folder after receiving thefiles
repeat with thisfile in thefiles
tell application "Finder"
set pathname to thisfile as alias
set the_file_name to thisfile as string
set AppleScript's text item delimiters to "-"
set folder_name to words -8 thru -6 of the_file_name as string
if folder named folder_name in folder photos_archive exists then
move thisfile to folder folder_name of folder photos_archive replacing yes
else
set pub_date_folder to make folder in folder photos_archive
set name of pub_date_folder to folder_name
move thisfile to folder folder_name of folder photos_archive replacing yes
end if
set AppleScript's text item delimiters to ""
end tell
end repeat
end adding folder items to
I use the standard OS X tool Image Capture for importing my digital images from the camera to the Mac.
When all photos have been imported Image Capture automatically starts a small freeware program called ExifRenamer that reads the Exif Data out of the photo files and then renames each file.
ExifRenamer also has the possibility to start a program when it is finished. Last evening I compiled your script and told ExifRenamer to start it. The conseqeuence was that it only processed a single file.
Therefore I thought it would be a could idea to alter the script at the beginning in that way that it takes all files from folder X (in my case the subfolder called “Import” which I created in my users home folder) for processing.
The script is a droplet… were you looking for a script to run by clicking, and it targets your folder?
property photos_archive : "hard drive name:Users:username:Import:"
tell application "Finder" to set theFiles to files of photos_archive
repeat with thisfile in thefiles
tell application "Finder"
set pathname to thisfile as alias
set the_file_name to thisfile as string
set AppleScript's text item delimiters to "-"
set folder_name to words -8 thru -6 of the_file_name as string
if folder named folder_name in folder photos_archive exists then
move thisfile to folder folder_name of folder photos_archive replacing yes
else
set pub_date_folder to make folder in folder photos_archive
set name of pub_date_folder to folder_name
move thisfile to folder folder_name of folder photos_archive replacing yes
end if
set AppleScript's text item delimiters to ""
end tell
end repeat
An adaptation of Mindtpi’s script. Save as application with options never show startup screen, don’t stay open.
property photos_import : “Internal Harddisc 80GB:Users:fotos:Import:”
property photos_archive : “Internal Harddisc 80GB:Users:fotos:Fotos:”
tell application “Finder” to set theFiles to files of alias photos_import
and now it works.
So as you can see I appended the source folder and appended “alias” to the “tell application …” line.
Once again THANK’S A LOT !
I had not found a solution on my own in such a short time.
Today I ordered an Applescript book at Amazon*'s. (Applescript - The Missing Manual)
Question for you- I have a very similar project, only my files begin with folder names. So inside my main folder “files” there it contains several files and sub folders for example: 100_august.pdf, 100_manual.pdf, 501_report.pdf, etc… I want these files moved to the corresponding folders 100, 501, etc…
Is it possible to have this script tweeked to work for my case? HELP?!