Need help with -if expression and MediaLanguageCode

Started by meecect, March 06, 2013, 02:14:24 PM

Previous topic - Next topic

meecect

I'm trying to find all media that has spanish language soundtracks.  In a previous topic, I was taught that -a anf -G1 can identify the language of the tracks.  After fiddling around with find, I saw the helpful tip on the front page that I should probably look into -ext and -if, so here I am ;-)

Running this command:

exiftool -a -g1 -ext m4v -MediaLanguageCode -System:FileName  *

I get this:

<snip>

======== ULTIMATE AVENGERS 1.m4v
---- System ----
File Name                       : ULTIMATE AVENGERS 1.m4v
---- Track2 ----
Media Language Code             : eng
---- Track3 ----
Media Language Code             : spa
---- Track4 ----
Media Language Code             : und
======== Ultimate Avengers II.m4v
---- System ----
File Name                       : Ultimate Avengers II.m4v
---- Track1 ----
Media Language Code             : und
---- Track2 ----
Media Language Code             : und

</snip>

So, now I just want the ones that have a 'spa' track.  I tried this:

exiftool -a -g1 -ext m4v -MediaLanguageCode -System:FileName  -if "$MediaLanguageCode eq 'spa'" *

and this:

exiftool -a -g1 -ext m4v -MediaLanguageCode -System:FileName  -if "$MediaLanguageCode == 'spa'" *

but neither returned any results.  Perhaps I misunderstand the -if option.  Any hints?

thanks,

(extremely awesome tool, btw)

Phil Harvey

The problem is that if you just specify "$MediaLanguageCode" it will pull out only one of them (likely not the one you wanted).  Unfortunately, to do what you want is a bit painful, but can be done:

exiftool -if "$track1:MediaLanguageCode eq 'spa' or $track2:MediaLanguageCode eq 'spa' or $track3:MediaLanguageCode eq 'spa' or $track4:MediaLanguageCode eq 'spa'" ...

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