Created
May 5, 2016 19:20
-
-
Save kaleksandrov/58eed0d9676db0f7fec74c56a3b26631 to your computer and use it in GitHub Desktop.
Revisions
-
kaleksandrov created this gist
May 5, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ #!/bin/sh case $# in 1) FROM="$1" TO="$1" ;; 2) FROM="$1" TO="$2" ;; *) echo "Usage: $0 <from-folder-or-file> <optional:to-folder-or-file>" exit 1 ;; esac IFS='' if ! [ -e "$FROM" ] then echo "The source path is invalid: $FROM" exit 2 elif [ -d "$FROM" ] then FROM=$FROM/*.* if ! [ -d "$TO" ] then echo "The destination file does not exists: $TO" exit 3 fi elif [ -f "$FROM" ] then FROM=$FROM if [ -e "$TO" -a -d "$TO" ] then TO="$TO$(basename $FROM)" fi fi for FILE in $FROM do SIMPLE_FILE="$(basename $FILE)" EXTENSION="${SIMPLE_FILE##*.}" FILENAME="${SIMPLE_FILE%.*}" echo '------------' ffmpeg -i "$FILE" -vn -acodec libmp3lame -ac 2 -ab 320k -ar 48000 "$TO/$FILENAME.mp3" echo '------------' done unset IFS