if condition fails when I try to move files, but not to just look at tags

Started by TinCanFury, October 31, 2021, 01:11:09 PM

Previous topic - Next topic

TinCanFury

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!

Phil Harvey

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

TinCanFury

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!

Phil Harvey

This exact problem is mentioned in the 4th paragraph of the Notes section of the file renaming page, but this could also be deduced by reading about the -d and -n and/or -p options in the application documentation.  Also, the Value Conversions section of the "Under the Hood" page explains more about the value conversions that are applied.

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

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

StarGeek

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/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype