Guest User

Untitled

a guest
Jul 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################
  3. # Bulk-unrar
  4. # Extracting rar archives from a directory
  5. # Requierments: unrar
  6. ######################################################
  7.  
  8. while getopts d: option
  9. do
  10. case $option in
  11. d)
  12. conf_dir=$OPTARG
  13. ;;
  14. esac
  15. done
  16.  
  17. fnExtract()
  18. {
  19. cd $conf_dir
  20. ARCH=`ls | grep rar`
  21. for i in ${ARCH[@]};
  22. do
  23. unrar -y x $i > /dev/null 2>&1
  24. done
  25. }
  26.  
  27. fnExtractPart01()
  28. {
  29. cd $conf_dir
  30. ARCH=`ls | grep part01`
  31. for i in ${ARCH[@]};
  32. do
  33. unrar -y x $i > /dev/null 2>&1
  34. done
  35. }
  36.  
  37. if [ "$2" = "" ]
  38. then
  39. echo "Usage: -d [directory] "
  40. else
  41. if [ -d $conf_dir ]
  42. then
  43. PART01=`ls | grep part01 | wc -l`
  44. if [ $PART01 = 1 ]
  45. then
  46. fnExtractPart01
  47. else
  48. fnExtract
  49. fi
  50. else
  51. echo "bunrar: $conf_dir: No such file or directory."
  52. fi
  53. fi
Add Comment
Please, Sign In to add comment