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)
@Lady @wallhackio i don't think you can do it in a Makefile in a way that is reliable since files can have newlines in them but 99% of the time it would be fine so whatever
@Lady @wallhackio POSIX has allowed newlines in a filename since furever
@aescling @wallhackio you are the operator of your computer, not POSIX
@aescling @wallhackio (did you know that a file with the name `Icon´ followed by a carriage return is how macOS has stored folder icons since forever? 🌠)
@Lady @wallhackio no i did not
@aescling @wallhackio files cannot have newlines in them that is absurd
they can have spaces in them however,,