用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
慕森卡
相关分类