shell中find命令用法
程序员文章站
2022-04-30 17:21:18
...
文件命名为t1.sh,在sh中运行bash t1.sh 指定目录,其中目录下包含.WAV文件,%号是将通配符,匹配.WAV前面的名字
target_dir=$1
fnames=(`find $target_dir -name "*.WAV"`)
echo $fnames
for fname in "${fnames[@]}"
do
mv "$fname" "${fname%.WAV}.nist"
sndfile-convert "${fname%.WAV}.nist" "$fname"
if [ $? = 0 ]; then
echo renamed $fname to nist and converted back to wav using sndfile-convert
else
mv "${fname%.WAV}.nist" "$fname"
fi
done