hey @vaporeon_ is there a good way to parallelize the following bash script I'm using to convert FLACs to MP3s?
#!/usr/bin/env bash
find "./${1}" | while read -r file; do
case $(file -b "${file}") in
'FLAC '*)
echo "${file}"
ffmpeg -nostdin -i "${file}" -ab 320k -map_metadata 0 -id3v2_version 3 "${file%flac}mp3" -v 16
;;
*)
;;
esac
done
@wallhackio this motherfucker typed esac
@wallhackio if you are doing `${file%flac}mp3"´ anyway can¦t you just switch on file extension rather than making a call to `file´?
if it were me i would parallelize this by using GNU Make which has a parallelization option
probably, to get all the functionality you want, creating some default rules to generate a %.mp3 from a %.flac and a fallback match-anything rule that treats its target as a directory (using FORCE) with secondary expansion to set the child files as dependencies from the target name dynamically (i think that works…)
but i¦m sure there is a more sane way
@Lady @wallhackio i think file is fur a recursive directory search? otherwise yeah he overengineered it (and unreliably so at that)
@aescling @wallhackio *find. find is for that.
file is just for getting the type of the file