ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: dsam on December 15, 2020, 02:58:10 PM

Title: Problem with -if option in args file - "Condition: Bad name after mimetype"
Post by: dsam on December 15, 2020, 02:58:10 PM
My goal is to find files that are saved as an image (e.g.: jpg, png, heic) but that are in fact a video file (Google Photos takeout export outputs Live Photos as .jpg/.heic)

I have an arguments file that contains the following options (livePhotos.args):

-r
-m
-q
-fast
-p
'$filename,$mimetype'
-v
-if
'mimetype =~ "video/"'
--ext
mov
--ext
mp4
--ext
avi
--ext
mpeg
--ext
json
--


When invoking the tool as: exiftool -@ livePhotos.args /directory-containing-images/, this is the output I get:

Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4931.JPG
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4929.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4932.JPG
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4928(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4930.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4933.JPG
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4927.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4924.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4946.MOV.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4926.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4930.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4929(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4934.JPG
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4930(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4931.JPG.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4928.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4925.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/metadata.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4926(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4926.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4934.JPG.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4927(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4929.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4925(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4927.HEIC.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4925.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4924.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4924(1).HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4932.JPG.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4933.JPG.json
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4928.HEIC
Condition: Bad name after mimetype' - /directory-containing-images/2020-01-01/IMG_4935.MOV.json
-------- /directory-containing-images/2020-01-01/IMG_4931.JPG (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4929.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4932.JPG (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4928(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4930.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4933.JPG (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4927.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4924.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4946.MOV.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4926.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4930.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4929(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4934.JPG (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4930(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4931.JPG.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4928.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4925.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/metadata.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4926(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4926.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4934.JPG.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4927(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4929.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4925(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4927.HEIC.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4925.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4924.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4924(1).HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4932.JPG.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4933.JPG.json (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4928.HEIC (failed condition)
-------- /directory-containing-images/2020-01-01/IMG_4935.MOV.json (failed condition)


When invoking it from the command line as exiftool -r -m -q -fast -p '$filename,$mimetype' -if '$mimetype =~ "video/"' --ext mov --ext mp4 --ext avi --ext mpeg --ext json -- /directory-containing-images, this is what I get:
IMG_4928(1).HEIC,video/quicktime
IMG_4929(1).HEIC,video/quicktime
IMG_4930(1).HEIC,video/quicktime
IMG_4926(1).HEIC,video/quicktime
IMG_4927(1).HEIC,video/quicktime
IMG_4925(1).HEIC,video/quicktime
IMG_4924(1).HEIC,video/quicktime


Why does using the args file fails and how do I fix it? Thanks 👍
Title: Re: Problem with -if option in args file - "Condition: Bad name after mimetype"
Post by: StarGeek on December 15, 2020, 03:08:02 PM
From the docs on the -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE)
   Normal shell processing of arguments is not performed, which among other things means that arguments should not be quoted

so  '$filename,$mimetype' and 'mimetype =~ "video/"' should not have the single quotes around them.
Title: Re: Problem with -if option in args file - "Condition: Bad name after mimetype"
Post by: dsam on December 15, 2020, 03:43:14 PM
Thank you very much, that did it for me!  :)