ExifTool Forum

ExifTool => Newbies => Topic started by: TinCanFury on October 31, 2021, 01:11:09 PM

Title: if condition fails when I try to move files, but not to just look at tags
Post by: TinCanFury on October 31, 2021, 01:11:09 PM
This works,
$ exiftool -if '($Make =~ /Apple/ and $DateTimeOriginal gt "0")' -DateTimeOriginal -Make .
======== ./IMG_2589.JPG
Date/Time Original              : 2014:05:06 20:11:50
Make                            : Apple
======== ./IMG_3582.JPG
Date/Time Original              : 2014:10:10 21:57:05
Make                            : Apple
======== ./IMG_3901.JPG
Date/Time Original              : 2014:12:06 22:08:49
Make                            : Apple

But this doesn't (for any single file or for the whole directory of files),
$ exiftool -v -if '($Make =~ /Apple/ and $DateTimeOriginal gt "0")' "-filename<$DateTimeOriginal" -d /media/storage/1/media/Photos-new/George/ToSort/%f.%%le IMG_3901.JPG
-------- IMG_3901.JPG (failed condition)
    1 files failed condition

however, if I remove the if statement the second statement works, but of course, I can't make sure the file matches my requirements.

I don't understand why adding the commands to move the file fails the condition.
Thanks for the help!
Title: Re: if condition fails when I try to move files, but not to just look at tags
Post by: Phil Harvey on October 31, 2021, 01:27:59 PM
First, I assume you are on Mac or Linux because you are using single quotes for the -if argument.

If so, you need to also use single quotes instead of double quotes for '-filename<$DateTimeOriginal'.

The problem is your -d option affects the value of DateTimeOriginal in the -if condition as well.  To fix this, use $DateTimeOriginal# instead of $DateTimeOriginal in your -if condition.

- Phil
Title: Re: if condition fails when I try to move files, but not to just look at tags
Post by: TinCanFury on October 31, 2021, 01:47:35 PM
yes, linux!

ah, interesting about the # and the -d option affecting it. do you mind pointing me to documentation on that so I can learn more about the issue?

also, as you can see from my string I just want to move the file not rename it (other than perhaps lower-casing the extension. Is there a better way to do this than the method I've chosen?

thanks!
Title: Re: if condition fails when I try to move files, but not to just look at tags
Post by: Phil Harvey on October 31, 2021, 02:00:10 PM
This exact problem is mentioned in the 4th paragraph of the Notes section of the file renaming page (https://exiftool.org/filename.html#Notes), but this could also be deduced by reading about the -d and -n and/or -p options in the application documentation (https://exiftool.org/exiftool_pod.html).  Also, the Value Conversions section of the "Under the Hood" page (https://exiftool.org/under.html#conversions) explains more about the value conversions that are applied.

If you just want to move the file, write Directory instead of FileName.

- Phil
Title: Re: if condition fails when I try to move files, but not to just look at tags
Post by: StarGeek on October 31, 2021, 02:35:41 PM
Quote from: TinCanFury on October 31, 2021, 01:47:35 PM(other than perhaps lower-casing the extension

To do this and move, you would still have to use Filename, but you include the directory
exiftool '-File=/media/storage/1/media/Photos-new/George/ToSort/%f.%le' /path/to/files/