Skip to content

Instantly share code, notes, and snippets.

@atrull
Last active June 4, 2020 10:12
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 atrull/256f1930b2ce35326c558544115313ad to your computer and use it in GitHub Desktop.
Save atrull/256f1930b2ce35326c558544115313ad to your computer and use it in GitHub Desktop.
A little utility to turn directories of flacs into mp3s, ideal for phones and other limited storage devices
#!/bin/bash
# a little utility to turn flacs into mp3s - helpful for getting more music on phones etc
# run this in the top level of directories you want to convert content to
# this does files AND directories and removes the flacs too - remove the "rm" if you don't want that function
# by alex (ataroba) trull (dottydotness) org
# turn all the flacs into v0 mp3s and deletes the flac files
# requires the ffmpeg utility
find . -type f -name "*.flac" -execdir sh -c 'ffmpeg -i "$1" -aq 0 -c:a libmp3lame -q:a 0 -map_metadata 0 "${1%.flac}.mp3" && rm "$1"' Cvt {} \;
# rename the directories to v0 if they contained flac or FLAC
# requires the rename utility
find . -type d -print0 -regex ".*(flac|FLAC).*" | rename -0 -e 's/(flac|FLAC)/v0/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment