Photos with no EXIF data - copy to alternate folder and rename if exists?

Started by Chromag, April 24, 2021, 09:32:53 PM

Previous topic - Next topic

Chromag

Hi All,

First - just found the tool today and it's great.  I'm trying to organize almost 20 years of photos (20K+) and I'm getting pretty close with exiftool.  I'm running the following to copy them from their original locations into a new YYYY/MM/filename folder and naming the new files based on the EXIF DateTimeOriginal.  Here is the command I'm using so far:

exiftool -o . -m -d %Y/%m/%Y%m%d_%H%M%%-c.%%e '-filename<CreateDate' '-filename<DateTimeOriginal' -r /photos

This works great but I have a situation where around 500 or so images have no EXIF data.  I get the following error:

Warning: No writable tags set from /photos/2006-01/whatever.jpg

That's fine and makes sense.  It currently just copies whatever.jpg into the root output folder.  However, I have some situations where I have another photo that is /photos/2008-11/whatever.jpg.  When it tries to copy to that root folder I get an error that the file exists.  So I had a couple questions:

1.  Is there any way to have it append a counter to the filename for the files with no EXIF if a file already exists?  So in the end I would have whatever.jpg and whatever-1.jpg in that root folder.

2.  Can I have it output these files with no EXIF data to an alternate folder like unknown/whatever.jpg instead of the output directory root?

I just want to make sure that when this process is complete EVERY file from the original location exists in the new location.  I don't want to lose a single photo during this process.  By having them all in a separate folder (and with an appended counter so they don't get lost) it will be easier to look at the thumbnails in that folder and deal with them manually.

Thanks!

StarGeek

Quote from: Chromag on April 24, 2021, 09:32:53 PM
1.  Is there any way to have it append a counter to the filename for the files with no EXIF if a file already exists?  So in the end I would have whatever.jpg and whatever-1.jpg in that root folder.

2.  Can I have it output these files with no EXIF data to an alternate folder like unknown/whatever.jpg instead of the output directory root?

Any time you assign a value to a tag in the same command, subsequent assignments take priority.  But if that subsequent assignment can't be done, it falls back to the previous assignment.  This is what you are doing when you first assign CreateDate to Filename followed by DateTimeOriginal.  The latter will take priority unless it doesn't exist, then it falls back to CreateDate.

So all you need to do is place another assignment before these two so it has a place to fall back upon.

Try this (test it first)
exiftool -o . -m -d %Y/%m/%Y%m%d_%H%M%%-c.%%e '-Filename=/path/to/Nodates/%f%-c.%e' '-filename<CreateDate' '-filename<DateTimeOriginal' -r /photos

The new fallback uses an equal sign instead of a less than sign because it doesn't contain a tag name such as CreateDate. See Common Mistake #5c.  For more details, also see Writing "FileName" and "Directory" tags  and details on the % tokens can be found under the -w (-TextOut) option.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Chromag

Genius!  This worked perfectly.  I also added the "%d" option to the unknown folder names and it maintained the old directory structure of the photos that had no valid EXIF data.  This will make it way easier to fix manually.  Thanks so much for your help!