'-if' and 'FileName', why does not work togeter?

Started by marcogaio, February 25, 2020, 12:11:42 PM

Previous topic - Next topic

marcogaio

I need to move/reorganize some photo, but filtering them by date (eg, older then...).

Photo metadata seems OK:

root@eraldo:~# exiftool -a -G1 -s -time:all /home/gaio/Immagini/arthur/2019/10/IMG_20191020_102048.jpg
[System]        FileModifyDate                  : 2019:10:20 22:15:46+02:00
[System]        FileAccessDate                  : 2020:02:25 17:13:30+01:00
[System]        FileInodeChangeDate             : 2020:02:25 17:09:52+01:00
[GPS]           GPSDateStamp                    : 2019:10:20
[GPS]           GPSTimeStamp                    : 07:10:23
[ExifIFD]       CreateDate                      : 2019:10:20 10:20:49
[ExifIFD]       SubSecTime                      : 000820
[ExifIFD]       DateTimeOriginal                : 2019:10:20 10:20:49
[ExifIFD]       SubSecTimeDigitized             : 000820
[ExifIFD]       SubSecTimeOriginal              : 000820
[Composite]     GPSDateTime                     : 2019:10:20 07:10:23Z
[Composite]     SubSecCreateDate                : 2019:10:20 10:20:49.000820
[Composite]     SubSecDateTimeOriginal          : 2019:10:20 10:20:49.000820


and if i try simply to search, the '-if' works:

root@eraldo:~# exiftool -r -if '$DateTimeOriginal le "2018:02:22"' /home/gaio/Immagini/arthur/2019/10/IMG_20191020_102048.jpg
    1 files failed condition
root@eraldo:~# exiftool -r -if '$DateTimeOriginal le "2020:02:22"' /home/gaio/Immagini/arthur/2019/10/IMG_20191020_102048.jpg
ExifTool Version Number         : 10.40
File Name                       : IMG_20191020_102048.jpg
Directory                       : /home/gaio/Immagini/arthur/2019/10
File Size                       : 1684 kB
File Modification Date/Time     : 2019:10:20 22:15:46+02:00
File Access Date/Time           : 2020:02:25 17:13:30+01:00
File Inode Change Date/Time     : 2020:02:25 17:09:52+01:00
[...]


But if i try to combine the '-if' with 'TestFile' (i've done also a test with 'FileName', and photo get effectively moved away...) seems that the 'if' condition does not match:

root@eraldo:~# exiftool -r -if '$DateTimeOriginal le "2018:02:22"' "-TestName<DateTimeOriginal" -d "/srv/casa/Foto/%Y/%m/%d/gaio-%%f.%%e" /home/gaio/Immagini/arthur/2019/10/IMG_20191020_102048.jpg
Warning: [minor] Unrecognized MakerNotes - /home/gaio/Immagini/arthur/2019/10/IMG_20191020_102048.jpg
'/home/gaio/Immagini/arthur/2019/10/IMG_20191020_102048.jpg' --> '/srv/casa/Foto/2019/10/20/gaio-IMG_20191020_102048.jpg'
    0 image files updated
    1 image files unchanged


I'm a bit puzzled... thanks.

Phil Harvey

The problem is that you are reformatting the date/time with -d, which also applies to $DateTimeOriginal in your -if condition.

Change $DateTimeOriginal to $DateTimeOriginal# in your -if condition to avoid reformatting the date/time here.

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

marcogaio

A-Ha! Bingo!

Sorry, i've read i think carefully docs and manpage, but i've totally missed that.

In hindsight, the line in -TAG section of the manpage:

A "#" may be appended to the tag name to disable the print conversion on a per-tag basis (see the -n option).  This may also be used when writing or copying tags.

looks relevant.

Thanks.