News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Problem when using -d and -if arguments together

Started by badigast, October 22, 2017, 04:26:32 PM

Previous topic - Next topic

badigast

Hello everybody

I'm trying to write a bash script that renames files that were taken within a specific date range.

#!/bin/bash

DATE1="2001:01:01"
DATE2="2003:12:31"
EVENTID="abc"

exiftool "-TestName<DateTimeOriginal" -d "${EVENTID}_%Y-%m-%d_%H-%M-%S%%-c.%%le" -If '$datetimeoriginal gt "'$DATE1'"' -If '$datetimeoriginal lt "'$DATE2'"' ./*


->  1 files failed condition

When I remove the -d argument the script works fine though:

exiftool "-TestName<DateTimeOriginal" -If '$datetimeoriginal gt "'$DATE1'"' -If '$datetimeoriginal lt "'$DATE2'"' ./*


It works with the -if argument removed, too:
exiftool "-TestName<DateTimeOriginal" -d "${EVENTID}_%Y-%m-%d_%H-%M-%S%%-c.%%le" ./*


When I use the -d in combination mit -if I always get the message that the condition failed.


Any help is much appreciated.

Thanks!


Phil Harvey

Adding the EVENTID to the start of your date/time values is messing up your comparison.

Use "$datetimeoriginal#" (ie. add the "#") to compare the unformatted date/time value in your -if condition.

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

badigast