I have a lot of audio files to convert and I like this to happen automatically when moving a folder with files into another folder, where the magic should happen. It's on a debian system.
Any help would be greatly appreciated.
I have a lot of audio files to convert and I like this to happen automatically when moving a folder with files into another folder, where the magic should happen. It's on a debian system.
Any help would be greatly appreciated.
Ensure you have inotifywait & ffmpeg installed, set the 3 vars at the start to the correct settings, then try
#!/bin/bash
watch_dir="WHEREEVER"
convert_from="flac"
convert_to="mp3"
inotifywait -qmr -e 'move,close_write'
--include ".${convert_from}" --format '%w%f%0'
--no-newline "$watch_dir" |
while IFS= read -r -d '' file
do
ffmpeg -i "$file" -ab 320k
-map_metadata 0 -id3v2_version 3
"${file/%.${convert_from}/.${convert_to}" > "$watch_dir"/log.txt 2>&1
rm -- "$file"
done
-r
switch means it will look recursively. If you want to call your own script, then just replace the 2 ffmpeg
& rm
lines. However I would advise against it as I am not sure you understand how it works.
– Bib
Nov 14 '23 at 12:05
ffmpeg
& rm
lines with the name of your own script & have that script accept just a single argument & act upon it. You will probably need to adjust the convert_from
var to something meaningful. It's just a simnple regex. Oh, and that script came pretty much out of the man page for inotifywait
.
– Bib
Nov 14 '23 at 15:18