Last active
March 6, 2017 11:07
-
-
Save mutoo/f341c9de7136361370a1ced0a5ee301c to your computer and use it in GitHub Desktop.
wav2mp3
This file contains hidden or 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 | |
| process() { | |
| dir=$@ | |
| echo "processing $dir/" | |
| FILES=$@/* | |
| IFS=$(echo -en "\n\b") | |
| for file in $FILES; do | |
| if [ -f "$file" ]; then | |
| # echo "found file $file" | |
| if [[ $file == *.wav ]]; then | |
| dir=$(dirname "$file") | |
| fileWithoutExt=$(basename "$file" .wav) | |
| mp3file="$dir/$fileWithoutExt.mp3" | |
| if [ -f "$mp3file" ]; then | |
| echo "$mp3file already exist" | |
| else | |
| echo "converting $file..." | |
| lame "$file" | |
| fi | |
| if [ force ]; then | |
| rm -f "$file" | |
| echo "removed $file" | |
| else | |
| rm -i "$file" | |
| fi | |
| fi | |
| elif [ -d $file ]; then | |
| # echo "found directory $file" | |
| process $file | |
| fi | |
| done | |
| } | |
| while getopts "f" arg; do | |
| case $arg in | |
| f) | |
| force=true | |
| ;; | |
| esac | |
| done | |
| process $(pwd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment