Guest User

Unrar shell script for downloaded RAR-ed stuffs...

a guest
Aug 10th, 2010
115
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Maybe not the best one, but useful for me... ;-)
  3. DIRS=". cd1 cd2 CD1 CD2 Cd1 Cd2"
  4. UNRAR="unrar x "
  5. WAIT=3
  6. STR="Waiting for ${WAIT} seconds, and deleting RARs..."
  7.  
  8. echo "=== START ==="
  9. for dir in ${DIRS}; do
  10. {
  11.     if [ ! -d ${dir} ]; then
  12.         continue;
  13.     fi
  14.     echo "=== Trying to extract rars from '`pwd`/${dir}' ==="
  15.  
  16.     if [ -e ${dir}/*.part1.rar ]; then
  17.         ${UNRAR} ${dir}/*.part1.rar;
  18.         echo "=== ${STR} ===";
  19.         sleep ${WAIT}
  20.         rm ${dir}/*.rar;
  21.         rmdir ${dir} &> /dev/null || true;
  22.     elif [ -e ${dir}/*.part01.rar ]; then
  23.         ${UNRAR} ${dir}/*.part01.rar;
  24.         echo "=== ${STR} ===";
  25.         sleep ${WAIT}
  26.         rm ${dir}/*.rar;
  27.         rmdir ${dir} &> /dev/null || true;
  28.     elif [ -e ${dir}/*.part001.rar ]; then
  29.         ${UNRAR} ${dir}/*.part001.rar;
  30.         echo "=== ${STR} ===";
  31.         sleep ${WAIT}
  32.         rm ${dir}/*.rar;
  33.         rmdir ${dir} &> /dev/null || true;
  34.     elif [ -e ${dir}/*.rar ]; then
  35.         ${UNRAR} ${dir}/*.rar;
  36.         echo "=== ${STR} ==="
  37.         sleep ${WAIT}
  38.         rm ${dir}/*.r*;
  39.         rmdir ${dir} &> /dev/null || true;
  40.     else
  41.         echo "=== ^ Nothing to extract from here... ==="
  42.     fi
  43.     sync;
  44. };
  45. done
  46. echo "=== DONE ==="
RAW Paste Data