Page 1 of 1

Rename based on EXIF date

PostPosted: Mon Jun 24, 2013 12:43 am
by parole.sprekate
Hi all,

I'm trying to create a rule to rename pictures. My naming convention is YYYYMMDD_location_counter.ext, where:

    - YYYYMMDD is the date I took the picture, based on EXIF information
    - Location is where I took this picture. This information, in particulare, should be inherited from the folder name the picture is in. More on this later.
    - counter is a 4 digit counter that should restart from 0 every time the rule is applied

My target workflow is:
    1. Use Adobe DNG converter to convert the images to DNG and have the converted images put in a folder names To_be_Processed/location, where location will be set based on where I've taken the pictures (manually)
    2. Have Hazel to look for new content in the To_be_Processed folder and sub-folders and rename the picture according to the rule aforementioned, taking the location sub_foldername as the basename
    3. Have hazel to move the images into the following folder structure
      - Master/YYYY/Location/YYYYMMDD_location/ where
      - YYYY is taken from the EXIF of the picture
      - location is taken from the folder
      - YYYYMMDD_location is built based on the previous information

I imagine this may sound a little cumbersome, but this naming convention is the result of several years of progressive approximation and it serves a number of specific scopes. I used to manage this structure directly from Aperture, but I have decided to migrate to Lightroom which has not an equally flexible folder structure management feature, so I need to rearrange my workflow differently.

Any idea if this is possible in Hazel?

Thanks a lot for any help.

e.

Re: Rename based on EXIF date

PostPosted: Mon Jun 24, 2013 1:30 pm
by Mr_Noodle
Please do not post questions in the Tips forum. The sticky up top there says not to do this.

It should be doable except for the EXIF part. Hazel uses Spotlight to get at metadata and unfortunately, OS X's Spotlight importer seems to ignore the date taken from EXIF (though it will extract other bits, for some reason). You'll probably have to find a commandline tool to extract that date and use a script with Hazel.

Re: Rename based on EXIF date

PostPosted: Fri Feb 14, 2014 12:31 pm
by dhy8386
parole.sprekate wrote:Hi all,

I'm trying to create a rule to rename pictures. My naming convention is YYYYMMDD_location_counter.ext, where:

    - YYYYMMDD is the date I took the picture, based on EXIF information
    - Location is where I took this picture. This information, in particulare, should be inherited from the folder name the picture is in. More on this later.
    - counter is a 4 digit counter that should restart from 0 every time the rule is applied

Any idea if this is possible in Hazel?

Thanks a lot for any help.

e.


Attaching a series of 4 rules that I think accomplishes what you want, but you need to install Exiftool to properly read the EXIF info. You can download and install from here: http://www.sno.phy.queensu.ca/~phil/exiftool/

Then download the following zip file, extract the rules and add them to your To_Be_Processed folder in Hazel.

The only change you would need to make is in the final rule, Sort_into_Proper_Folders, the first embedded shell script runs an exiftool command and you need to set the path location to the top level Master folder (i.e. /username/photos/Master/). The sorting and sub sorting should then happen automatically.

The way the counter works is that if you drop a bunch of files in a Location folder, it will start numbering them 0001, 0002, etc. Once the contents of the Location folder are COMPLETELY emptied, the Reset_Folder_Counter rule runs to reset the counter for the next crop of files. FYI, until the counter token is run for the first time on a processed file, hazel will report a shell script error because its trying to reset an empty Location folder which has never received the counter attribute.

Let us know how it works for you.

Re: Rename based on EXIF date

PostPosted: Sat Feb 15, 2014 8:57 pm
by felciano
Very nice! Thanks for making this available.

Can you explain how the Sort_into_Proper_Folders action works? In particular, it looks like you are first calling the EXIFTool binary via shell script (exiftool '-Directory<CreateDate' -d /PATH/TO/MASTER/FOLDER/%Y "$1") but then also asking Hazel to do a "Sort into subfolder" operation. Doesn't the former handle the folder sorting for you?

Ramon

Re: Rename based on EXIF date

PostPosted: Sun Feb 16, 2014 7:50 am
by dhy8386
it certainly could but he is sorting into a special subfolder with date_location pattern. I thought it would be easier sort w this custom name pattern using Hazel then Exif tool. But if you wanted to sort w just EXIF you could do that by changing the format of %Y to something like %Y%m%

Re: Rename based on EXIF date

PostPosted: Sun Aug 17, 2014 3:20 am
by noodlepie
Im using the rule you gave as a downloadable example, but Id like to tweak the naming convention a bit. Im a novice at scripting, so any help would be appreciated...

Currently, the rule is...

IF KIND IS IMAGE

1) RUN SHELL SCRIPT [embedded]

SHELL /bin/bash
Code: Select all
exiftool -P -d '%Y%m%d' \
   '-filename<${FileModifyDate;}.%e' \
    '-filename<${GPSDateTime;}.%e' \
    '-filename<${MediaCreateDate;}.%e' \
    '-filename<${ModifyDate;}.%e' \
    '-filename<${DateTimeOriginal;}.%e' \
    "$1"


2) RENAME with pattern : [name] [extension]

This outputs a file with this pattern...
20140508.jpg
YYYYMMDD.jpg


I'd like to output as follows....
2010-10-04 at 21-41-41.jpg
YYYY-MM-DD at HH-MM-SS[.ext]


Any help would be appreciated!