我需要连接文件夹中的所有 wav 文件。
我尝试使用命令
sox folder_name/*.wav folder_name.wav
但是得到了错误
sox FAIL sox: Input files must have the same # channels
原来该文件夹中的 2864 个 wav 文件中只有 21 个有 2 个 channel 而不是 1 个。
我怎样才能忽略具有 2 个 channel 的 21 个文件并将所有 2843 wav 与 1 个 channel 连接起来?
最佳答案
使用soxi
要获取所有一个 channel 文件,请将它们放在一个数组中,然后调用 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
关于bash - 如果 #channels 为 2,则连接 wav 文件将忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47463252/