Created
December 26, 2013 11:26
-
-
Save AnotherKamila/8132573 to your computer and use it in GitHub Desktop.
My shell scripts for music management
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR="`readlink -f \"${1:-.}\"`" | |
FLAC_MUSIC_DIR="`readlink -f \"${2:-$HOME/temp/flac_music/}\"`" | |
Q=8 | |
echo " ** Encoding all FLAC files under $DIR as OGG at quality $Q **" | |
find "$DIR" -type f -name '*.flac' -print | while read -r f; do oggenc -q$Q -o "${f%.flac}.ogg" "$f"; done | |
echo " ** Moving all FLAC files to $FLAC_MUSIC_DIR **" | |
find "$DIR" -type f -name '*.flac' -print | while read -r f; do | |
mkdir -p "`dirname \"$FLAC_MUSIC_DIR/${f#$DIR}\"`" | |
mv -v "$f" "$FLAC_MUSIC_DIR/${f#$DIR}" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reads an m3u playlist and copies the files somewhere, optionally passing them through a program | |
PLAYLIST="_playlists/sync.m3u" | |
DEST_FOLDER="$HOME/_sync/music" | |
# called on every file with arguments $SOURCE $DEST_FOLDER | |
through() { | |
mkdir -p "$2/`dirname \"$1\"`" | |
# oggenc -q7 -o "$2/${1%.*}.ogg" "$1" | |
cp "$1" "$2/$1" | |
} | |
while read -r f; do | |
through "$f" "$DEST_FOLDER" | |
done < "$PLAYLIST" | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment