I am looking for a smart way to bulk rename directories in my photo library based on the date the pictures were taken.

My specific use case: Export the image library from iPhoto or Aperture on OS X to a more permanent and OS-independent file and folder structure.

The input list of directories would look like this:


The renamed output should look like this:

2012-02-01 - 2012-02-22
2012-03-14 - 2012-03-14 input_directory_name

The dates should be picked either from the creation dates of the pictures in the directory (oldest / newest date) or alternatively from the metadata of the files (JPEG, TIFF, RAW...).

If the input_directory_name is looking like a date "1.2.2012" then it should be skipped.

If the input_directory_name contains text the text should be added to the new directory name. Reason: Unnamed events in iPhoto / Aperture are autmatically tagged with a date which unfortunately has the badly sortable order of DD.MM.YYYY

I googled a bit but couldn't easily find a clever way - possibly someone else has encountered this issue before?

  • IIRC, the exitool manage page has examples for that. Nov 3 '12 at 23:49

First of all: if you are going to be trying solutions use a full copy or a copy of a subset of the pictures to avoid disaster.

You could try something along the lines of:

for folder in $(ls -l | awk '{print $9}'); 
    do <magic here>;

The magic could be something like using the identify command if this is available to you. From what I read it can read exif data from pictures. Based on this you could perhaps create a folder or move the directory etc etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.