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!
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
That worked perfectly.
Thanks a lot!