ExifTool Forum

ExifTool => Newbies => Topic started by: matze2ooo on September 02, 2012, 07:50:45 AM

Title: Copying and renaming pictures
Post by: matze2ooo on September 02, 2012, 07:50:45 AM
Hello exiftool users

I am trying to manage my chaotic photo library and would like to harmonize all the file names using exiftool version 8.60 running on linux. 

All the photos are distributed over several directories:
Quote
/home/my_user/Pictures
/home/my_user/Photos
/home/my_user/Photos/2012
[...]

Now the idea is to have all pictures in one folder:
Quote
/home/my_user/new_pic_folder

All files should have the following format afterwards:
Quote
2012_08_24 - 18:24:12 - original_filename.ext

I had a look at the man pages. And this seems to be a good start:

Quote
exiftool '-FileName<CreateDate' -d %Y_%m_%d-%H:%M:%S.%%e .

A few questions that came up:

* How can I now recursively iterate over the above mentioned source directories?
* How can include the original filename in the destination file name?
* How can I control exception cases where no exif information is available? And e.g. move it to a folder called lost+found.

Thanks in advance for your input on this
Matthias
Title: Re: Copying and renaming pictures
Post by: matze2ooo on September 02, 2012, 08:40:53 AM
I guess I have figured it out myself:  :P

Quote
$ exiftool -o /home/my_user/new_pic_folder -r '-FileName<CreateDate' -d %Y.%m.%d\ -\ %H:%M:%S\ -\ %%f /media/nas/Pictures /media/nas/Photos/
Title: Re: Copying and renaming pictures
Post by: Phil Harvey on September 02, 2012, 03:54:40 PM
Good.  The %f is the best way to do this, but you could have also done it like this:

exiftool ... '-filename<${createdate}${filename}' -d '%Y.%m.%d - %H:%M:%S - ' ...

About moving the ones without metadata (or, specifically without CreateDate) to a different directory...  You could do this:

exiftool -if 'not $createdate' -directory=DESTINATION_DIR -r SOURCE_DIR

...but it seems as if there may be some useful information in the original directory structure that you might loose by doing this.  If so, you could save (in the JPEG Comment for example) it when moving the files:

exiftool -if 'not $createdate' '-comment<directory' -directory=DESTINATION_DIR -overwrite_original -r SOURCE_DIR

(in this case, -overwrite_original was necessary to prevent the original from being preserved because we are writing some real metadata in the file with this command.)

- Phil
Title: Re: Copying and renaming pictures
Post by: matze2ooo on September 02, 2012, 04:25:23 PM
Will the following also copy files to "new_pic_folder" in an error/warning condition, e.g. when an image has no or corrupted exif information?


exiftool -r -F -o /home/my_user/new_pic_folder '-FileName<CreateDate' -d %Y.%m.%d\ -\ %H:%M:%S\ -\ %%f.%%e /media/nas/Pictures /media/nas/Photos/ > exiftool.log 2>&1


I see many of the following error messages flying by:


Warning: [minor] Unrecognized MakerNotes - MY_FILE.jpg
Warning: No writable tags found - MY_FILE.jpg
Warning: Bad PreviewIFD directory - MY_FILE.jpg
Warning: [minor] Overlapping MakerNotes values - MY_FILE.jpg
Warning: Bad PreviewIFD offset for tag 0x2 - MY_FILE.jpg
Warning: Unknown format (513) for PreviewIFD tag 0x100 - MY_FILE.jpg
Warning: Bad NikonScanIFD directory - MY_FILE.jpg
Title: Re: Copying and renaming pictures
Post by: Phil Harvey on September 02, 2012, 06:38:21 PM
The warnings are from reading other metadata, but as long as ExifTool can still read the CreateDate then the file will get renamed.  But if you get an error ("Error:" instead of "Warning:"), then the file isn't renamed.

However, some of these warnings may cause errors if you actually try to write metadata to the file.

- Phil