I would need your help with ExifTool. I am trying to check if all of my .wav files have the same amount of channels through meta-data. How should I proceed? Should I print out the tags first and then write a script to check if they are all the same or is there a better way? Thank you for your help.
Asked
Active
Viewed 102 times
1
-
1You want to check "same metadata", or just check "same number of channels"? – L. Scott Johnson Jul 02 '19 at 15:29
-
Same number of channels, updated the title – ambersv Jul 02 '19 at 15:46
-
1If you want to compare against a specific number of channels, you can use the [`-if` option](https://sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html#if-NUM-EXPR) like this `-if "$NumChannels==2"` or `-if "$NumChannels>1"` to get a specific list of files that don't meet the criteria. But exiftool doesn't have a way to compare one file to another. If you are unsure of the number of channels to start with, you would need to script. – StarGeek Jul 02 '19 at 15:53
1 Answers
0
You'd have to do it externally (via a file or your shell controls or something.
e.g., in bash:
if [ "$(exiftool -NUMCHANNELS a.wav)" == "$(exiftool -NUMCHANNELS b.wav)" ]
then
echo match
fi
To see if many files all match, you could do something like
exiftool -q -NUMCHANNELS *.wav | uniq | wc -l
And verify the output is 1

L. Scott Johnson
- 4,213
- 2
- 17
- 28
-
-
1.. in bash? Set a variable to the value for one of the files and then compare that value (in a for loop) to all the files. – L. Scott Johnson Jul 02 '19 at 16:32
-
1Or you could pipe it all through `uniq` and see if you get more than one line. I'll add that to my answer – L. Scott Johnson Jul 02 '19 at 16:39