Mailinglist Archive: opensuse (3618 mails)

< Previous Next >
[opensuse] Organize Your Digital Photos - exiftool and jhead
  • From: "David C. Rankin" <drankinatty@xxxxxxxxxxxxxxxxxx>
  • Date: Wed, 28 Jan 2009 13:33:05 -0600
  • Message-id: <4980B2F1.7080200@xxxxxxxxxxxxxxxxxx>
Listmates,

I've been meaning to pass this snippet along. I believe it was Patrick
that
pointed me to exiftool some time back. Organizing you mass of digital pictures
couldn't be any easier than with exiftool or jhead. Both available for openSuSE
and, for your friends that don't use linux, each has a windows counterpart that
runs from the command prompt.

Many of you already know, but for those that don't, one of the biggest
pains
about digital cameras is organizing the hundreds or thousands of 103Z2987.jpg
files into a meaningful file structure that allows you to find pictures when you
need them.

A filename like 103Z2987.jpg doesn't tell me anything about that photo
except
that it came from my wife's camera because I set her camera to create 103Z...
files. What I want in a filename is information that tells me when the picture
was taken that will sort in chronological order no matter what I am looking at
them with. I like a filename of the form YYYY-mm-DD-HHMMSS.jpg. For example:

2009-01-27-165238.jpg

That way, just by looking at the filename, I know exactly when that
photo was
taken.

Both exiftool and jhead provide the perfect solution. They will read
the exif
data and rename the photos with the format you provide. (the format parameters
are from strftime). exiftool is a bit more flexible because, not only will it
rename for you, but it will move the resulting files to where ever you want
them.

I had thousands of files in an awkward directory structure partially
created
from digikam and partially created by copying the photos from the memory stick.
With one basic command line, I was able to rename and reorganize everything into
a logical structure by year, by months 1-12, and then by date and time in each
month. Example:

2003
2004----
01
02
03-------
2004-03-05-174331.jpg
2004-03-05-174522.jpg
2004-03-07-082311.jpg
04
..
12
2005
...
2009

The man page for exiftool is quite good (see the example section at the
bottom)
I used the following command to reorder everything into the directory structure
above using the exif tag 'CreateDate' for the file name:

exiftool -r '-FileName<CreateDate' -d \
/home/pictures/family_pictures/%Y/%m/%Y-%m-%d-%H%M%S.%%e \
year2004/*.jpg

Basically, the command just says recursively read each .jpg file, get
the
'CreateDate' (date picture was taken) and use that as the filename and then
place the renamed picture in the /home/pictures/family_pictures/ directory,
under the %Y (year) subdirectory it belongs in, then in the %m (month)
subdirectory it belongs in, with the filename of %Y-%m-%d-%H%M%S
(YYYY-mm-DD-HHMMSS) preserving the original extension (.%%e)

The only issue I had was with the (-r) option not wanting to recursively
descend into all subdirectories. Changing the filespec to */*.jpg would get me
one additional level of subdirectories, so I ended up just issuing the command
8-9 times and changed the filespec information (dir1/*.jpg, dir2/*.jpg, etc.) to
go through all my picture directories. (I actually wanted to do the first couple
one-at-a-time just in case something went wrong) Of course, the find command or
'for i in $(ls)....' would automate the process.

Also, don't forget the -i (ignore) option if you have directories you
don't
want reorganized. I had ../scaled directories in each of my photo directories
where I had scaled images to 800x600 for the digital picture frame that I needed
to ignore.

Absolutely Amazing. I re-ordered just over 8,000 photos in a little
less that
30 minutes. (that included reading the man page and messing around with the
filespec) If you can get all the files in one command, I bet the 8,000 photos
would have been done in less than 3 minutes total.

I did a little more thorough write up that is available at:

http://www.3111skyline.com/linux/photo-mgmt.php

The page is done for exiftool and jhead, but I still have the gallery2
information to add.

Just thought I would pass this along for the benefit of those that
haven't
found exiftool and jhead yet.

--
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >