Will Godfrey, Sep 19 2015:
I have about 150 uncompressed audio files that I want
to properly categorise,
relatively quickly.
The very oldest were recorded as 16bit 44.1k, more recent ones were 16bit, 48k
and the latest ones 24bit 48k.
I've moved them all into the same directory, so is there a simple script I can
run that will scan this and list the name and details of each file?
I can find plenty of programs that can change the format, but can't find any
that will just tell me what it is :(
Hey hey,
This script will do the main work, you can replace the sndfile-info lines with exiftool
lines, remember to change the grep expression.
***
#!/bin/bash
PID=$$
for F in *; do
sndfile-info "$F" &>audio-format-${PID}.log
SR=`cat audio-format-${PID}.log | grep -e "^Sample Rate" | awk '{
split($0,myarr,":"); print myarr[2] }'`
CHNLS=`cat audio-format-${PID}.log | grep -e "^Channels" | awk '{
split($0,myarr,":"); print myarr[2] }'`
BITS=`cat audio-format-${PID}.log | grep -e "Bit Width" | awk '{
split($0,myarr,":"); print myarr[2] }'`
echo "file: $F, samplerate: $SR, bit width: $BITS, channels $CHNLS"
# Insert conversion code here...
# Remember to put a semicolon after the last command in here!
done
rm audio-format-${PID}.log
***
I do like the exiftool output even better, since it tells you the format clearly, in case
an extension is wrong and you'd need a different conversion tool for some outlandish
format.
Good luck!
...
Ta-ta
----
Ffanci
* Homepage:
https://freeshell.de/~silvain
* Twitter:
http://twitter.com/ffanci_silvain
* GitHub:
https://github.com/fsilvain