ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: richardl152 on March 28, 2021, 01:58:09 PM

Title: -o output batch directory - avoiding duplicates
Post by: richardl152 on March 28, 2021, 01:58:09 PM
I have a working GPS and date combined search as per the script below.   Unsurprisingly it complains about duplicate files.   Apologies if a FAQ but how can I get the program to auto renumber duplicates.   I tried using all combinations of the %c  formatting I could think of but nothing seems to work.     



#!/bin/bash                                                                                                                                                     
echo "search_name latitude longitude margin 1e-4 and eg dates 2019:01:01 2020:12:31"
mkdir -p $HOME/GPS_Search/"$1"
exiftool  -if \
         '($createdate# gt "'$5'") and ($createdate# lt "'$6'") and   \                                                                                         
         (abs($gpslatitude# - "'$2'") < "'$4'")  and (abs($gpslongitude# - "'$3'") < "'$4'") '   \
         -o $HOME/GPS_Search/"$1"   -r .


Title: Re: -o output batch directory - avoiding duplicates
Post by: StarGeek on March 28, 2021, 02:34:41 PM
Does $1 contain a filename or a path?  If the latter then try something like
-o $HOME/GPS_Search/"$1"/%f%-c.%e

If the former, than you'll probably have to parse that somehow before passing it to exiftool.
Title: Re: -o output batch directory - avoiding duplicates
Post by: richardl152 on March 28, 2021, 02:56:58 PM
Its just an output directory.   thanks

eg

exiftool_find_GPS_and_date  CornExchangeCambridge 52.1 0.11 0.01  "2021:03:01" "2021:03:30" 2>/dev/null


creates an output directory with the name CornExchangeCambridge to hold the results
Title: Re: -o output batch directory - avoiding duplicates
Post by: StarGeek on March 28, 2021, 04:24:29 PM
Try making the command work on the command line before trying to put it in a script.
Title: Re: -o output batch directory - avoiding duplicates
Post by: Luuk2005 on March 29, 2021, 11:02:23 PM
Greetings Richard.
This what Im learned from the experiments: The only way to fix is using the variables like StarGeek says.

Because if $1=CornExchangeCambridge, and there is not already a folder named CornExchangeCambridge...
Then for every input file, exiftool tries to create 1-file called.. "CornExchangeCambridge"
But with $1/%f%-c.%e, it instead names the duplicates like. "CornExchangeCambridge/InputName-#.ext"

But even with using $1/ or passing CornExchangeCambridge/ to say FolderNameOnly...
Then for every input file, exiftool tries to create a file called.... "CornExchangeCambridge/InputName.ext"
So there could never be a second file with the same InputName.ext, because nothing is using %c.

So if you already experimented with %c, Im thinking the quotes did probably just get typod somehow.
I see many quotes here like -o '/Path/%f%-c.%e', but not knowing how this changes inside the scripts????
For me, its Windows wanting things more like "%%c", so Im interested to see how to fix your script.