organise Photos iteratively and idempotent

Started by fido, March 26, 2020, 10:20:13 AM

Previous topic - Next topic

fido

Hi,

I'm trying to organise a bunch of photos that I find over time in my grown it-infrastructure.
I am looking for an idempotent way to iteratively add new photos while not affecting existing ones in "archive".

In short:
- an "import" folder where to drop recently found photos (regardless of creation date)
- a script that organises photos from "import" into the "archive"
- organise photos in Folderstructure according to Exif CreateDate Information, taking care of Year and Month.
- name files according to Exif CreateDate and model of the camera, that was used for creation {DMC-G6, TZ-31, Motorola G5, Nesus 5X, etc.}
- take care if photos would be imported, that are already in place

As you might get in the following lines I'm not very familiar with exiftool, may be there is a more elegant way to solve things. I'm very happy to get your feedback on this. I'm currently using a two-step-approach for organising photos, due to lack of knowledge (probably?).

My key question is: if there is a way to solve the idempotency issue.

Meaning I would like to add photos and especially (first step) and
rename them afterwards according to my "conventions (second step),
avoiding renaming all existing photos then.

I'm adding my current Steps (not scripted, yet) to provide you as much information as possible to get my point.


####
# Check for conflicts with existing fotos
# - this will take a lot of time
# - will prevent if someone tamperes manually the destination folder
####

# will recursevily create a list of hashes in Import folder
md5deep -r -l $IMPORT_FOLDER |sort -k32 > $IMPORT_HASHES

# should provide a list of duplicates in destination folder
md5deep $DESTINATION_FOLDER -r -M $IMPORT_HASHES

####
# Import Images if no duplicates are identified
####

# may be those two could be handled with one command?

exiftool -o . '-Directory<CreateDate' -d $DESTINATION_FOLDER/%Y/%Y_%b -r $IMPORT_FOLDER

exiftool '-filename<${CreateDate}_${model;}.%le' -d %y%m%d_%H%M%S%%-c -r -ext jpeg -ext jpg $DESTINATION_FOLDER


Thank you for your feedback and suggestions!

Phil Harvey

You can do the moving/renaming in one step:

exiftool '-filename<${CreateDate}_${model;}.%le' -d "$DESTINATION_FOLDER/%Y/%Y_%b/%y%m%d_%H%M%S%%-c" -r "$IMPORT_FOLDER"

If you want to avoid moving/renaming existing photos, then remove the "%%-c" from the format string.  This will of course not move photos which are different, but have the same date/time and camera model.   I don't really understand what you are wanting, so I don't know how you would like to handle these.

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

fido

Hi Phil,

thank you for the very helpful feedback.

The "oneliner" does help me to get rid of my biggest problem ;-) in this topic.

If someone is checking this post, at a later time: I was using -o to keep a "safe" copy of the files first.
With the Code-Sample, please keep (Linux-)quotation rules in mind  :) I screwed some things up with using single quotes accidentally.


exiftool -o "$DESTINATION_FOLDER" '-filename<${CreateDate}_${model;}.%le' -d "$DESTINATION_FOLDER/%Y/%Y_%b/%y%m%d_%H%M%S%%-c" -r -ext jpg -ext jpeg "$IMPORT_FOLDER"


The "%%-c" adds a counter if two photos where shot in time, which uses to happen at some time in my case, so I need to keep it probably. I would like to avoid adding another enlargement like shutter-count or sth. more uniqe to the filename.

I observed a very welcome behavior in my testings:  I kept some equal photos in different sub-folders, and only one of them was taken (with recursive processing) into the archive, even though I was using %%-c.

So two last questions:
Went something wrong and this happend accidentally?
Does exiftool check wether source file and target file are the same or not?

Phil Harvey

Quote from: fido on March 27, 2020, 03:56:03 PM
I kept some equal photos in different sub-folders, and only one of them was taken (with recursive processing) into the archive, even though I was using %%-c

With your command, the only reason a file shouldn't be copied to the destination folder is if it doesn't have both CreateDate and Model tags.  ExifTool does not check to see an existing target file is the same before applying %%-c.

Note that in your command, "-o ." will suffice because the directory will be overridden by the one set in FileName (see example 11 here for details).

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