Skip to content

Instantly share code, notes, and snippets.

@stevekm
Last active April 17, 2017 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevekm/b803b6c084cc4f073f904e545336305d to your computer and use it in GitHub Desktop.
Save stevekm/b803b6c084cc4f073f904e545336305d to your computer and use it in GitHub Desktop.
Extract archives and convert FLAC's to mp3 on OS X / macOS
#!/bin/bash
input_dir="$1"
printf "Input dir is:\n%s\n\n" "$input_dir"
# this script will extract all of the archive files it finds with p7zip
# first install p7zip
# brew install p7zip
# list of passwords to try, space delimited
passwords="soitgoes"
find "$input_dir" \( -name '*.zip' -o -name '*.rar' -o -name '*.7z' \) | while read item; do
for pword in $passwords; do
7z x "$item" -p${pword} -y
echo ""
done
done
# ~~~~~~~~~ # # ~~~~~~~~~ # # ~~~~~~~~~ # # ~~~~~~~~~ # # ~~~~~~~~~ #
# this script will convert all FLAC files to v0 mp3
# designed for use on OS X/macOS
# first you need to install the ffmpeg library
# brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265
# brew update && brew upgrade ffmpeg
# make sure it worked
# ffmpeg
# convert all the .flac files in the current directory to v0 mp3
divder="---------------------------------"
find "$input_dir" -name "*.flac" -print0 | while read -d $'\0' item; do
(
output="${item%%.flac}.mp3"
printf "\n%s\n" "$divder"
printf "\nINPUT FLAC:\n%s\n\n" "$item"
printf "\nOUTPUT MP3:\n%s\n\n" "$output"
set -x
ffmpeg -y -i "$item" -aq 0 "$output" < /dev/null
set +x
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment