How to include camera model in directory name

Started by Matt Calthrop, August 31, 2011, 07:05:38 AM

Previous topic - Next topic

Matt Calthrop

Hi all.

First time user of exiftool - loving its power & flexibility, but have a requirement that I have not yet found a solution for.

I want to rename a bunch of files, creating date-based directories (ie, based on the date the photo/video was taken), and include the camera model in name of the directory (not in the file name).

For example, if the photo called IMG_4458.JPG was taken on my iPhone 3GS on 12 September 2011 at 13:55:24, I want the file renamed like this:

2011/09/12 - iPhone 3GS/20110912_135524_4458.JPG

(ideally, I'd like the JPG transformed to lower case too).

The reason for this is so that I can easily see which photos have been taken by which device (if anyone has any alternative solution to achieve the same effect, I'm all ears!).

From the experimentation I have done so far, I can discover how to put the camera model only in the file name, but not the directory name.

Anyone got any suggestions?

Thanks in advance,

Matt

Phil Harvey

Hi Matt,

This is tricky because you have two different date formats with other information in between.  You can either create a user-defined tag, or do this in 2 steps:

1) rename the file:

exiftool -d %Y%m%d_%H%M%S_%%-4f.%%e "-filename<datetimeoriginal" DIR

2) move the file to the new directory:

exiftool -d %Y/%m/%d "-directory<$datetimeoriginal - $model" DIR

where DIR is the name of the directory containing the images.  The 2nd command will root the new directory hierarchy in the current directory, but you may change this to wherever you want by specifying a destination directory name before $datetimeoriginal.

Note: Use double quotes as above in Windows, or single quote on Mac/Linux.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Matt Calthrop

Wow -- superfast reply!  Thanks Phil.

I had worked out the first command, but the second one evaded me (and had not thought of a 2 stage process).

And I'm not worried about having to do it in two steps -- will give that a go when I get home.

Am using a bash shell script on a Mac, btw.

Matt

Matt Calthrop

Ok, that works fine for me (with some minor modifications).

However, I exiftool can't find the datetimeoriginal tag for .mov files (ones created on an iPhone).

I have substituted this with CreateDate, and it seems to be producing the same results as datetimeoriginal (but finding the timestamp for the .mov files of course).

Do you know of any pros/cons of using CreateDate instead of datetimeoriginal?

Matt

Phil Harvey

For all digital cameras, CreateDate and DateTimeOriginal are the same.  CreateDate refers to the time the file was created (when the image was digitized), and DateTimeOriginal refers to when the image was captured.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).