I use the following shell script to unpack all RAR files in a directory and all subdirectories. The script supports both the old and new RAR naming conventions (both .rar, .r00, .r01, … AND .partXX.rar styles).
#!/bin/bash set -e archives="rar partrar" unpack_rar() { name=`echo "$1" | egrep '^.*[.]rar$' | egrep -v "[.]part[0-9]+[.]"` if [ ! -z "$name" ]; then basename=`echo "$name" | sed 's/\.rar$//g'` basetrunc=`basename "$basename"` dirname=`dirname "$name"` rar x -vy "$name" "$dirname" && find "$dirname" -regextype posix-egrep -regex ".*$basetrunc.*.r(ar|[0-9]+)\$" -print0 | xargs -0 -n1 rm -f else return 1 fi return 0 } unpack_partrar() { name=`echo "$1" | egrep '^.*[.]part0+1[.]rar$'` if [ ! -z "$name" ]; then basename=`echo "$name" | sed 's/\.part0\+1\.rar$//g'` basetrunc=`basename "$basename"` dirname=`dirname "$name"` rar x -vy "$name" "$dirname" && find "$dirname" -regextype posix-egrep -regex ".*$basetrunc.*.rar\$" -print0 | xargs -0 -n1 rm -f else return 1 fi return 0 } find . | while read file; do for arc in $archives; do unpack="unpack_$arc" $unpack "$file" && break done done