I am trying to use the exiftool to sort my collection of photos by moving them into a year\month hierarchy eg. 2010\Jan\ based on the time the photos were taken without any modifications. Here is what I've already got.
exiftool -r -v5 "-Directory<DateTimeOriginal" -d "%Y/%b/" $1 >> /var/log/jpegsort.log
The problem is I get the following errors:
Error: '2004/Dec/PC240020.JPG' already exists - new/PC240020.JPG
Warning: [minor] Suspicious MakerNotes offset for tag 0x1033 - new/P8270050.JPG
Warning: [minor] Adjusted MakerNotes base by 3940 - new/016.JPG
I believe exiftool automaticaly corrects the MakerNotes error. I want to preserve the original. How do I stop this?
I would also like to move any duplicates the script finds to a separate folder.
How do I extend my script to do this?
First, the "'2004/Dec/PC240020.JPG' already exists" error can be avoided using %c to avoid name collisions when moving a file, ie)
exiftool -r -v "-filename<datetimeoriginal" -d "%Y/%b/%%f%%-c.%%e" ...
Second, ExifTool will not modify an image if only writing "pseudo" tags like Directory. The warning comes from the reading stage because ExifTool first reads the file to extract the DateTimeOriginal tag. You can do a "diff" or generate an MD5 checksum to compare the file before and after moving if you want to verify this.
- Phil
I followed your suggestion but now get the following:
stdout:
Warning: Bad MakerNotes offset for tag 0x1033 - dest/2006/Jul/P7180025.JPG
Error creating directory 2006/Jul/P7180025.JPG
logfile:
======== dest/2006/Jul/P7180025.JPG
Setting new values from dest/2006/Jul/P7180025.JPG
'dest/2006/Jul/P7180025.JPG' --> '2006/Jul/P7180025.JPG/P7180025.JPG'
I don't understand what is happening. What is your exact command line?
It looks like ExifTool is trying to create a directory which is the file name itself, so somehow you must be writing the filename twice to the FileName tag.
- Phil
I'm using bash, my command line:
exiftool -r -v "-Directory<DateTimeOriginal" -d "%Y/%b/%%f%%-c.%%e" SRC_DIR >> /var/log/jpegsort.log
Ah, yes. That's the problem. You are writing the Directory tag instead of the FileName tag.
- Phil
OOps... I did not notice the -filename tag.
That should work now however this will create copies if the filename already exists. I was really hoping to try and avoid having duplicate photos in the destination directory. It would mean that I would have to view and compare each of the duplicates files to ensure it was an actual copy and not a filename clash of two different photos.
Another problem that I can see is if I ran the script on the already sorted directory (destination dir).
Do I need to supply the -P option to preserve the modify date when moving?
OK then. If you don't want files with duplcate names to be copied you should go back to your original command. I only suggested this to get around the Error mentioned in your original post.
You don't need to use -P when just moving a file.
- Phil