Posts tagged: unrar

two-line bash script to extract all rars in a given folder

By , 2013-02-15 12:15

This script will find all .rar files in a given directory and extract them into the specified directory. Requires the unrar binary installed in PATH.

usage: unrar-recursive.sh [directory to scan] [extraction destination dir]

  • Running the script without arguments will search for all .rar files in the current directory and subdirectories and extract them all to the current working directory.
  • Running the script with only 1 argument will search for all .rar files in the specified directory and extract them into the same directory.
#!/bin/bash
if [ "$#" -eq 0 ]; then dest=$1; else dest=$2; fi
find $1 -type f -iname "*.rar" -exec unrar e {} $dest \;

Sources:

Custom theme by me. Based on Panorama by Themocracy