我需要一个在 Linux 终端中使用的 bash 脚本,其内容应类似于:
#!/bin/bash
for textgrid_file in ./*.TextGrid and for wav_file in ./*.wav
do
praat --run pitch.praat "$textgrid_file" "$wav_file" >> output.txt
done
即我需要迭代扩展名为 .textgrid
和 .wav
的文件对,因为在我的 Praat 脚本 pitch.praat
中,我有两个参数要传递。如何通过 bash 脚本实现它?
最佳答案
您可以使用数组支持来迭代第一个 glob 模式并使用数组中的第二个文件:
waves=(*.wav)
k=0
for textgrid_file in *.TextGrid; do
praat --run pitch.praat "$textgrid_file" "${waves[k++]}" >> output.txt
done
关于bash - 从 bash 脚本循环多个文件扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49103942/