ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: anibeasts on December 23, 2010, 04:35:58 PM

Title: Moving/Sorting Files based on date with duplicates
Post by: anibeasts on December 23, 2010, 04:35:58 PM
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?
Title: Re: Moving/Sorting Files based on date with duplicates
Post by: Phil Harvey on December 24, 2010, 07:36:21 AM
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
Title: Re: Moving/Sorting Files based on date with duplicates
Post by: anibeasts on December 25, 2010, 09:22:22 AM
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'



Title: Re: Moving/Sorting Files based on date with duplicates
Post by: Phil Harvey on December 25, 2010, 02:57:21 PM
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
Title: Re: Moving/Sorting Files based on date with duplicates
Post by: anibeasts on December 25, 2010, 07:45:48 PM
I'm using bash, my command line:
exiftool -r -v "-Directory<DateTimeOriginal" -d "%Y/%b/%%f%%-c.%%e"  SRC_DIR  >> /var/log/jpegsort.log
Title: Re: Moving/Sorting Files based on date with duplicates
Post by: Phil Harvey on December 26, 2010, 06:43:27 AM
Ah, yes.  That's the problem.  You are writing the Directory tag instead of the FileName tag.

- Phil
Title: Re: Moving/Sorting Files based on date with duplicates
Post by: anibeasts on December 29, 2010, 08:28:59 AM
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? 
Title: Re: Moving/Sorting Files based on date with duplicates
Post by: Phil Harvey on December 29, 2010, 08:47:49 AM
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