Created
September 2, 2016 09:19
-
-
Save shantur/1eab3b8e8b427392c3dc35e491647a29 to your computer and use it in GitHub Desktop.
Converts all mp4 files in a folder tree to another folder tree
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 | |
# loop & print a folder recusively, | |
recurse() { | |
echo $1 $2 $3 | |
for i in "$1"/*;do | |
if [ -d "$i" ];then | |
outputdir=`echo $i | sed "s/$2/$3/g"` | |
echo "outputdir: $outputdir" | |
mkdir -p "$outputdir" | |
recurse "$i" "$2" "$3" | |
elif [ -f "$i" ]; then | |
outputfile=`echo $i | sed "s/$2/$3/g"` | |
outputfile=`echo $outputfile | sed "s/mp4/mp3/g"` | |
convert "$i" "$outputfile" | |
fi | |
done | |
} | |
convert() { | |
input=$1 | |
output=$2 | |
ffmpeg -i "$input" -vn -ab 256 "$output" | |
} | |
echo "convert from path: $1 to $2" | |
mkdir -p "$2" | |
recurse "$1" "$1" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment