#!/bin/bash whereis unrar 1>/dev/null 2>&1 || exit 0 RAR="$(find "$(pwd)" -maxdepth 1 -type f -iname "*.rar"|head -n 1)" N="$(find "$(pwd)" -maxdepth 1 -type f -iname "*.r*"|egrep "r[0-9]*$"|wc -l)" ls "$(dirname "${RAR}")" > /tmp/before.$$ echo "${N} archives in '"$(basename "$(dirname "${RAR}")")"'" echo -n "Extracting..." unrar e "${RAR}" 1>/dev/null 2>&1 if [ $? -eq 0 ] then echo " done" else echo " failed" exit 1 fi rename "s/\.img/\.iso/g" *.img 1>/dev/null 2>&1 ls "$(dirname "${RAR}")" > /tmp/after.$$ AFTER="$(diff "/tmp/before.$$" "/tmp/after.$$"|egrep '>'|cut -b 3-)" echo "Successfully extracted '${AFTER}'" rm /tmp/after.$$;rm /tmp/before.$$