用vim写个bash脚本,判断某个文件是否存在,如果存在,调用ffmpeg将文件夹下以FLAC1_ 开头的扩展名为.flac的文件转换为mp3格式
#!/bin/bashFFMPEG_BIN="ffmpeg-4.0.1/ffmpeg"MUSIC_PATH="music"if [[ -d ${MUSIC_PATH} ]]; thenecho "MUSIC_PATH exists."flac_files=find ${MUSIC_PATH} -name "FLAC1_*.flac"if [[ -z "${flac_files}" ]]; thenecho "No flac files in directory ${MUSIC_PATH}"exitfiecho "Start to convert flac format to mp3 format"for input_file in ${flac_files}dooutput_file=${input_file/flac/mp3}echo -e "\n${input_file} ==> ${output_file}"${FFMPEG_BIN} -i "$input_file" -ab 320k -map_metadata 0 "${output_file}"doneelseecho "MUSIC_PATH doesn't exist."fi
添加回答
举报
0/150
提交
取消