Last active
March 4, 2017 04:19
-
-
Save undermink/096c525301151797bcfdfb8297fe8ec8 to your computer and use it in GitHub Desktop.
A simple script to convert audiofiles from one format into another using ffmeg and minor eyecondy...
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 | |
# convert all files in the cwd to antoher format using ffmeg | |
clear; | |
# some eyecandy first :) | |
for i in {16,16,22,28,34,40,76} ; do echo -en "\e[48;5;${i}m \e[0m" ; done; | |
for i in {0..5} ; do echo -en "\e[48;5;76m \e[0m" ; done; | |
echo -en "\e[1m\e[97m\e[48;5;76mconverting audiofiles with ffmpeg\e[0m" | |
for i in {0..5} ; do echo -en "\e[48;5;76m \e[0m" ; done; | |
for i in {76,40,34,28,22,16,16} ; do echo -en "\e[48;5;${i}m \e[0m" ; done ; echo; | |
echo | |
# ask for input output formats | |
echo " ==> what is the format of the files want to convert? <==" | |
read inputformat | |
echo " ==> what is the desired outputformat? <==" | |
read outputformat | |
# loop through all files of the given format | |
for f in *.$inputformat; | |
do | |
# convert the audiofile | |
ffmpeg -i "$f" ${f%.*}.$outputformat; | |
echo -e "\e[104m\e[1m\e[97m$f => ${f%.*}.$outputformat \e[0m"; | |
done | |
# check if we have as many old files as new ones | |
echo " ==> checking files <==" | |
echo | |
# count files | |
COUNT1=`ls -alh *.$inputformat | wc -l` | |
COUNT2=`ls -alh *.$outputformat | wc -l` | |
if [ "$COUNT1" -eq "$COUNT2" ] ; | |
then | |
echo -e "\e[1m\e[48;5;76m;\e[97m [x] ok \e[0m"; | |
else | |
echo -e "\e[1m\e[101m\e[97m !!! Error !!! \e[0m"; | |
fi | |
echo -e "$COUNT1 $inputformat-Dateien || $COUNT2 $outputformat-Dateien" | |
echo | |
# delete the old files | |
echo " ==> do you wnat me to delete all $inputformat-files? [y|N] <==" | |
read answer | |
case $answer in | |
y|Y|yes|Yes|YES) | |
# use -i for safety :) | |
rm *.$inputformat -i | |
;; | |
n|N|No|no|*) | |
echo " ...ok :)" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment