Reputation:
I need to concatenate all the wav files in a folder.
I tried using the command
sox folder_name/*.wav folder_name.wav
But got the error
sox FAIL sox: Input files must have the same # channels
Turns out only 21 of 2864 wav files in that folder have 2 channels instead of 1.
How can I just ignore the 21 files with 2 channels and concatenate all the 2843 wavs with 1 channel?
Upvotes: 2
Views: 964
Reputation: 42999
Use soxi
to get all one channel files, put them in an array and then call sox
:
for file in folder_name/*.wav; do
if soxi "$file" | grep -q 'Channel.*1'; then
files+=("$file")
fi
done
sox "${files[@]}" folder_name.wav
Upvotes: 1