问题描述
我有一个运行时一个任务下载完成后,看是否有FLAC的音频文件,如果是将其转换为MP3的脚本。直到今天我用:
I've got a script that runs when a torrent download is finished to see if there are FLAC audio files and if yes convert them to MP3. Until today I've used:
for file in "$torrentpath"/"$torrentname"/*.flac
do
ffmpeg -i "$file" -qscale:a 0 "${file[@]/%flac/mp3}"
done
但我意识到,当一个洪流来到含子目录剧本是没用的。我试着插科打诨过去几天查找和如果等方式,但我实在看不出答案。我知道它的存在。
But I realised that when a torrent comes containing sub-directories the script is useless. I've tried messing around for the past few days with "find" and "if" and other ways but I can't really see the answer. I know it's there.
脚本应该只是测试是否有子显示目录和执行这些ffmpeg的,否则直接与转换去了。
The script should just test if there are sub-dirs and execute ffmpeg on those, otherwise directly go with the conversion.
任何一点蛛丝马迹将AP preciated。
Any little hint will be appreciated.
推荐答案
要处理任意子目录在bash:
to handle arbitrary subdirectories in bash:
shopt -s globstar nullglob
for file in "$torrentpath/$torrentname"/**/*.flac
do ...
这篇关于转换上并不总是有目录中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!