我的文件列表如下所示:
S134_001.wav
S134_002.wav
S134_003.wav
S149_001.wav
S149_002.wav
S149_003.wav
S16_001.wav
S16_002.wav
S16_003.wav
S16_004.wav
S16_005.wav
S16_006.wav
S272_001.wav
S272_002.wav
S272_003.wav
S272_004.wav
S272_005.wav
S272_006.wav
S272_007.wav
S374_001.wav
S396_001.wav
S92_001.wav
我想将S134_001.wav,S134_002.wav,S134_003.wav合并为S134.wav; S149_001.wav,S149_002.wav和S149_003.wav进入S149.wav;等等(最好使用sox)。
我也想删除原始文件。
我如何实现这一目标? Bash是首选的解决方案,但任何编程语言都可以。感谢。
答案 0 :(得分:1)
您可以像这样使用for循环:
for f in *_001.wav
do
pre=${f%%_001.wav}
# use either cat or sox or whatever works:
#cat "${pre}_"*.wav > "${pre}.wav"
sox -m "${pre}_"*.wav "${pre}.wav"
#rm -rf "${pre}_"*.wav
done
rm
命令之前删除注释。