Created
December 23, 2014 13:37
-
-
Save JonTheNiceGuy/fe0d7e82db05db1ce4c4 to your computer and use it in GitHub Desktop.
Migrate audio files to OGG format
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/sh | |
if [ -z "$2" ]; then | |
dpath=/media/usb0/Multimedia/Audio/ | |
else | |
dpath="$2" | |
fi | |
if [ -z "$3" ]; then | |
spath="`pwd`" | |
else | |
spath="$3" | |
fi | |
src=`find "$spath/$1" -type f -maxdepth 1 2>/dev/null | wc -l` | |
dst=`find "$dpath/$1" -type f -maxdepth 1 2>/dev/null | wc -l` | |
if [ "$dst" -eq "0" ]; then | |
echo "WARNING: $1 does not exist in $dpath" | |
elif [ "$src" -ne "$dst" ]; then | |
echo "" | |
echo "$src ----------------------------- $spath/$1" | |
ls "$spath/$1" | |
echo "$dst ----------------------------- $dpath/$1" | |
ls "$dpath/$1" | |
else | |
echo "OK - $1 has the same number of entries" | |
fi |
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 | |
out_target="$3" | |
if [ "$out_target" == "" ]; then | |
out_target="/media/usb0/Multimedia/Audio/Artists/" | |
fi | |
file_path="`dirname \"$1\"`" | |
file_name="`basename \"$1\" .$2`" | |
in_file="$file_path/$file_name.$2" | |
out_path="$out_target/$file_path" | |
out_file="$out_path/$file_name.ogg" | |
in_size=`du -h "$1" | awk '{print \$1}'` | |
echo -n "Converting $file_path/$file_name" | |
mkdir -p "$out_path" | |
nice -n 15 sox "$in_file" -t vorbis "$out_file" | |
out_size=`du -h "$out_file" | awk '{print \$1}'` | |
echo " - Done (went from $in_size to $out_size)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment