Last active
January 11, 2016 01:59
-
-
Save AbdallaZaki/b14bbebe08adca5d9863 to your computer and use it in GitHub Desktop.
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 | |
cd ~/Downloads | |
filetounrar=$(ls ./*.rar -t | head -n1) | |
function unrarmyfile () | |
{ | |
rar e "$filetounrar" | |
} | |
function userchoose () | |
{ | |
echo "[r]eplace [q]uit" | |
while read -r line ; do | |
if [ $line == "r" ]; then | |
unrarmyfile | |
elif [ $line == "q" ]; then | |
exit 1 | |
else | |
userchoose | |
fi | |
done | |
} | |
if [[ -f "$filetounrar" ]] ; then | |
moviesfiles=$(rar lb "$filetounrar" | grep "\.\(mkv\|mp4\|rmvb\|flv\|mov\)$") | |
if [ -f $moviesfiles ]; then | |
userchoose | |
else | |
unrarmyfile | |
fi | |
if [ $? -eq 0 ] && [ ! -z "$moviesfiles" ]; then | |
if [ -z "$( pgrep totem )" ]; then | |
echo "$moviesfiles" | xargs -d "\n" totem & | |
else | |
echo "$moviesfiles" | xargs -d "\n" totem | |
fi | |
fi | |
else | |
echo "there is no file to unrar" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment