The following shell script takes a video file as input and converts it into mp3 file at users home directory.Ensure that the file name is specified in double quotes if it contains any whitspaces.
====================================================
#!/bin/sh
folder="/home/$USER/Music"
name=""
if [ -z "$1" ]
then
echo "No file name specified "
echo "Please provide the absolute path of the file Ensure that the file name is enclosed in single quotes"
exit 1
fi
echo "Output file name?"
read name
ffmpeg -i "$1" -acodec libmp3lame -ab 160k -ar 44100 -ac 2 "$folder/$name"
if (($? != 0 ))
then
pacman -Q lame ffmpeg > /dev/null
if (($? !=0))
then
echo "Please ensure that lame and ffmpeg are installed on your system"
exit 2
else
echo "No such file exists"
exit 3
fi
fi
echo "File successfully converted"
exit 0
===================================================
====================================================
#!/bin/sh
folder="/home/$USER/Music"
name=""
if [ -z "$1" ]
then
echo "No file name specified "
echo "Please provide the absolute path of the file Ensure that the file name is enclosed in single quotes"
exit 1
fi
echo "Output file name?"
read name
ffmpeg -i "$1" -acodec libmp3lame -ab 160k -ar 44100 -ac 2 "$folder/$name"
if (($? != 0 ))
then
pacman -Q lame ffmpeg > /dev/null
if (($? !=0))
then
echo "Please ensure that lame and ffmpeg are installed on your system"
exit 2
else
echo "No such file exists"
exit 3
fi
fi
echo "File successfully converted"
exit 0
===================================================
0 comments:
Post a Comment