Truly unique filenames for photos without relying on 'c'.

Started by blueryu, October 13, 2017, 11:52:40 AM

Previous topic - Next topic

blueryu

In the past I've used this command:
exiftool -r -d F:/Destination/%Y/%m/%d/%Y%m%d_%H%M%S%%-c.%%e "-FileName<CreateDate" "-FileName<DateTimeOriginal" F:\Source

Which basically works fine. I use Windows by the way.

What I'm trying to do now is finding a round-about way of easily marking duplicates. The -c only works if the photos were not taken in the same second. There is also the chance of photos from different cameras getting the same timestamp.

So far it looks like I could integrate some of the composite values into the filename. It's just a matter of figuring out how to make it work, which I spent a few solid hours on yesterday without success. Probably went through 50 iterations of commands, haha.

Composite values I was referring to:
https://exiftool.org/TagNames/Composite.html

I'd like to continue with the standard date structure for directories (year / month / day).

For the filename I'd like to make them unique sub-second with data values that would be in the vast majority of photos (old JPEGs from the early 2000, DNGs, NEF, RAF, etc...). That basically means things like aperture, ISO, shutter speed. I can't rely on a value like SubSecDateTimeOriginal, because that won't be valid in most photos.

So in that case, It would be best to rely on valid (calculated) values I'd expect to be in the EXIF of all of those types.

Potential tags:
LightValue
WB_RGBLevels
HyperfocalDistance

That said, I'd like filenames to be something like:
HHMMSS-LightValue-HyperfocalDistance-WB_RGBLevels-c.ext

The validity or formatting (eg in HEX instead of decimal to shorter filenames?) isn't too important either way, I just want to get something unique between photos. That way, any photos that have -1, -2, -3 from 'c' are very likely duplicates.

How would I go about getting those three additional values into the filename? Having all of them would depend on how large the values are. I know LightValue is good for sure because that's usually small from values I've seen on the forum, but the other two, I don't know. I'd also need to format them by removing the decimal point (maybe scientific notation?).

An example of what I'd potentially want the filenames to look like:
100524-7p2-2p023231-3423423.nef
100524-7p2-2p023231-3423423-2.nef
100524-7p2-2p023231-3423423-3.nef
Where the decimal was replaced with 'p'.

Along with that, I'd like the filename to fall back on DateTimeOriginal when CreateDate isn't available, which is almost 100% of the time outside of video files.

Thanks to anyone that can help out! (I'll be making a Youtube tutorial video on backing up photos with EXIFTool being a big part of the process, once I get this ironed out.)



Phil Harvey

The user-defined tag feature is well suited to this sort of task.  You could create a user-defined Composite tag derived from the values of various tags and formatted however you want to get a unique string for the file name.

The possibilities of are endless, so I won't get into any more detail on this except to point you to the sample config file to see how user-defined Composite tags are created.

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

blueryu

I'm having trouble with even simple things like moving files into date based directories with a filename that has more than just date in it. Configuration files and custom tags are past what I want to get into.

My idea not is something more simple by just getting filename that have date, time, and file size.

Example Destination directory + filename:
G:/photos/year/month/date/YYMMDD-HHMMSS-FileSizeInBytes.ext

I have this so far:
exiftool -r "-TestName<${CreateDate;}-${FileSize#}%-c.%e" -d "G:/destination/%Y/%m/%d" G:/source/


Which output something like this:

'G:/source/2002/12/29/20021229_185304.jpg' --> 'G:/source/2002/12/29/Gdestination20021229-638479.jpg'
'G:/source/2002/12/29/20021229_185342.jpg' --> 'G:/source/2002/12/29/Gdestination20021229-1038332.jpg'


What I want (attempt CreateDate, fall back on DateTimeOriginal or whichever tags are better for photos in the order of when the photo was taken by the camera to the file creation date if no other option exists):

'G:/source/2002/12/29/20021229_185304.jpg' --> 'G:/destination/2002/12/29/20021229-HHMMSS-638479.jpg'
'G:/source/2002/12/29/20021229_185342.jpg' --> 'G:/destination/2002/12/29/20021229-HHMMSS-1038332.jpg'


That said, how do I get the files into the proper destination parent directory, and how do I get the time in there as well? It would also need to fallback onto DateTimeOriginal, so I assume that means two -filename parameters with the different tag (the order of operations is right to left? I need to take better notes when I'm reading the forum/man page)

Thanks to anyone that can help out!

Phil Harvey

I think if you just remove the semicolon after "CreateDate" you will have what you want:

exiftool -r "-TestName<${CreateDate}-${FileSize#}%-c.%e" -d "G:/destination/%Y/%m/%d" G:/source/

The semicolon causes characters that are illegal in file names to be filtered out, so the ":" and "/" characters are removed.  And without a "/" in the value, only the FileName is set instead of setting the Directory+FileName.

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