Creating folders for photos based on EXIF data in Mac OS X
October 7, 2015 9:58 AM   Subscribe

What's a safe, reliable app/script for creating folders and moving photos into them based on their EXIF creation date in Mac OS X?

My parents have photos all over their Mac with different folder naming conventions, and I'd like to organize them into a structure like:

2014
    2014-01-01
    2014-01-03
    ...
2015
    2015-01-06
    2015-01-10
    ...


Is there an app or script that I could throw the photos at that would read the EXIF creation date and create the folder structure and move the photos? (Of course I'd do a backup first.)

They use iPhoto (eventually Photos, when I upgrade them from Mavericks), which I'm not terribly familiar with. After I get this folder structure set up can I get iPhoto to import into the same structure?
posted by DakotaPaul to Computers & Internet (10 answers total) 1 user marked this as a favorite
 
ExifTool does the sorting into folders part, don't know about iPhoto.
posted by Bangaioh at 10:50 AM on October 7, 2015


Why do you want to organize the pictures before importing them into the Photos app? Photos will automatically organize your pictures according to EXIF creation date. So importing them will take care of the problem for you.

(If you are worried about duplicates, there are a number of solutions for that, albeit none of them perfect. Photos.app will do a rudimentary job off the shelf. There are third-party apps -- the one I use is called PhotoSweeper -- that improve on the duplicate detection in various ways.)
posted by alms at 10:53 AM on October 7, 2015


Response by poster: Thanks, Bangaioh! I have used ExifTool on my work PC for very basic tasks; I should have known it was powerful enough to do what I need here. Will give that a shot.

alms: I don't use iPhoto and wasn't sure it would do the organizing for me. My parents use iPhoto, but when I went to their Pictures folder they folders named YYYY MM DD, YYYY_MM_DD, and some photos just sitting in the root of Pictures. There were no YYYY folders with subfolders for each day, either.

They already have a bunch of photos in iPhoto, but tell me they've never done any editing or anything they want saved. Can I nuke the iPhoto library file and re-import everything again to create the folder structure I want?
posted by DakotaPaul at 10:58 AM on October 7, 2015


I think you're seriously misunderstanding both iPhoto and the new Photos applications. When they import photos, by default they copy the originals into their database, as well as making a variety of thumbnails etc. So you don't need to organize anything by date - in fact, you could move all the random photo folders into a big Junk/ folder and call it done. (I'm very hesitant to say you should actually delete them, because I'm inherently distrustful of monolithic software applications, but for non-technical parents? iPhoto / Photos is fine.)

For example: on their Mac, look at ~/Pictures/ folder. You should see iPhoto Library.migratedphotolibrary/ and Photos Library.photoslibrary/ and if you run du -hs * on those folders, you should see something like

$ du -hs Photos\ Library.photoslibrary/*
0B Photos Library.photoslibrary/Attachments
98M Photos Library.photoslibrary/Database
4.0K Photos Library.photoslibrary/Library.data
LOTS Photos Library.photoslibrary/Masters

That Masters folder already has the exact structure you're proposing, based on EXIF data - YYYY/DD/etc.

Likewise with their iPhotos Library - and if it says migratedphotolibrary, it has done something rather clever with hard links (not regular soft links) so that the photos appear to be in both iPhoto and Photos without consuming twice the disk space but are separately editable in each application.

Bottom line - clean up your parents random folders and put them away; their Photos library is already organizing things for them as long as they're importing regularly or automatically.
posted by RedOrGreen at 11:35 AM on October 7, 2015


2 other things:

(1) Do NOT nuke their iPhotos library - if they've deleted folders of photos before, the iPhotos library holds the only copy now.

(2) You should only use Photos going forward. iPhoto was creaking really badly at the seams for a long time and Photos is the ground-up rewrite that is better in almost every way.
posted by RedOrGreen at 11:37 AM on October 7, 2015


Response by poster: Thanks for the info, RedOrGreen. I use Lightroom and have it set up to import into ~/Photos/YYYY/YYYY-MM-DD; I didn't realize iPhoto also copies the photo into its own database as well.

Once I get this all sorted out and they start using only iPhoto/Photos to import, will the photos only import into the library database, and not also into another folder under ~/Photos?
posted by DakotaPaul at 11:54 AM on October 7, 2015


You can also do this in bash. Pardon my fondness for deprecated syntax:

#!/bin/bash
for image in `ls -1`; do export date=`mdls $image | grep ContentCreationDate | awk '{print $3}'`;
if [ -d ./$date/ ]
then
cp $image ./$date/
else
mkdir ./$date/ && cp $image ./$date/
fi;
done
exit

Put that block (from the hashbang to the exit) into an empty text file, name it somename.sh, and give it execution permissions. (chmod u+x somename.sh). Then, run from the directory in which your photos are; it will check the creation date on each one, check whether a folder exists for that creation date, make the folder if necessary, and sort them. (Copying them, to reduce the risk of catastrophically messing things up if there's a bug in there; not impossible since I knocked that script out in about ten minutes.)

This is assuming all the photos are in a single directory, though, so the solution you have is probably more workable.
posted by fifthrider at 11:56 AM on October 7, 2015


> Will the photos only import into the library database, and not also into another folder under ~/Photos?

Assuming you mean ~/Pictures here - how are they importing now? If they're using Image Capture and creating a folder, they could continue doing that. It adds a step (importing them into Photos after that) but is potentially safer if you're a hands-on geek; if not, it just adds confusion.

If they import directly using the Photos app, it won't create an extra folder, it will just import straight to the library. (And since the originals are still there, neatly organized by date, there's really not that much to fear - you can always back out of using Photos, move the folder out, etc.)

Just make sure they have good regular backups - that's far more important.

There's also the issue with PhotoStream, and what is or is not synced directly via the cloud. I've stayed away from that myself, so I can't help there.
posted by RedOrGreen at 12:08 PM on October 7, 2015


Response by poster: I think they've imported using a number of applications, including DropBox and possibly Photoshop Elements, which is why stuff is all over the place. When I have time I'll import into iPhoto everything that's in odd folders, then put them all into a separate folder.

And setting up Time Machine was one of the first things I had them do. :-)
posted by DakotaPaul at 12:23 PM on October 7, 2015


Oh, and here's a version that finds every image in ~/Pictures instead of just checking in the local directory.

#!/bin/bash
for image in `mdfind image -onlyin ~/Pictures`; do export date=`mdls $image | grep ContentCreationDate | awk '{print $3}'`;
if [ -d ~/Desktop/$date/ ]
then
cp $image ~/Desktop/$date/
else
mkdir ~/Desktop/$date/ && cp $image ~/Desktop/$date/
fi;
done
exit
posted by fifthrider at 12:40 PM on October 7, 2015


« Older Gate-checking a mobility scooter?   |   I'm on disability, and was told to resign. I feel... Newer »
This thread is closed to new comments.