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 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 file is for a recursive directory search but there is no reason why you can¦t call file in a makefile

Follow

@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

@aescling @wallhackio files cannot have newlines in them that is absurd

they can have spaces in them however,,

@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? 🌠)

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.