linux bash脚本跑不了大神看看哪错了《求代码》

用vim写个bash脚本,判断某个文件是否存在,如果存在,调用ffmpeg将文件夹下以FLAC1_ 开头的扩展名为.flac的文件转换为mp3格式

#!/bin/bash

FFMPEG_BIN="ffmpeg-4.0.1/ffmpeg"
MUSIC_PATH="music"

if [[ -d ${MUSIC_PATH} ]]; then
echo "MUSIC_PATH exists."
flac_files=find ${MUSIC_PATH} -name "FLAC1_*.flac"
if [[ -z "${flac_files}" ]]; then
echo "No flac files in directory ${MUSIC_PATH}"
exit
fi
echo "Start to convert flac format to mp3 format"
for input_file in ${flac_files}
do
output_file=${input_file/flac/mp3}
echo -e "\n${input_file} ==> ${output_file}"
${FFMPEG_BIN} -i "$input_file" -ab 320k -map_metadata 0 "${output_file}"
done
else
echo "MUSIC_PATH doesn't exist."
fi


慕容森
浏览 1047回答 1
1回答

慕森卡

这是代码和运行结果看看哪错了
打开App,查看更多内容
随时随地看视频慕课网APP