Copying and renaming pictures

Started by matze2ooo, September 02, 2012, 07:50:45 AM

Previous topic - Next topic

matze2ooo

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

matze2ooo

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/

Phil Harvey

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
...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 ($).

matze2ooo

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

Phil Harvey

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
...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 ($).