Unrar recursively multiple archives (linux and mac)

Tagged: Database, Programming, Ubuntu Date: 1st, August 2008

It really is a drag when you download full season of your favorite show and see 20+ episodes in separate folders, every episode rared. It takes a bit of time to unpack one by one.

Here’s a little script that should help you with that (and with similar tasks). Download.
Install:

gunzip unrarr.gz
sudo cp unrarr /usr/bin/
sudo chmod +x /usr/bin/unrarr

Usage:

unrarr /path/to/folder

Edit:
To check rar files (through svf files) for consistency CVF package must be installed (cfv.sourceforge.net)

10 Responses to “Unrar recursively multiple archives (linux and mac)”

  1. Markus Maier:

    Thx for the nice lil program, this is for sure a timesaver=)

  2. Robert:

    Brilliant tool thank you!
    I have an improvement however, currently your script reads
    [code]
    2)
    for f in `find $1 -wholename *.r01`
    do
    echo "Unpacking in directory: "`dirname $f`
    rar e -inul $f `dirname $f`
    done ;;
    [/code]
    This means that some packages cannot be unpacked (e.g. part01.rar – part20.rar).
    I could easily solve this by altering your script (instead of -wholename *.r01` I wrote -wholename *.part01.rar`) and saving it as unrarr2.
    This is however not the prettiest solution.
    Maybe you could add another IF – THEN line under 2?
    2a IF -wholename *.r01` THEN unpack
    2b IF -wholename *.part01.rar’ THEN unpack

    I would do it myself if I could but I know nothing of scripting, I only have a basic knowledge of logics.

  3. catohagen:

    you can give several suffixes to find :
    for f in `find $1 -path *.r01 -or -path *.part01.rar -or -path *.part1.rar

    to fix problem with files with spaces :

    for f in `find $1 -path *.r01 -or -path *.part01.rar -or -path *.part1.rar | sed -e ’s/ /[SPACE]/g’`

    then unescape files with :

    f=`echo $f | sed -e ’s/\[SPACE\]/ /g’`

    complete loop :

    for f in `find $1 -path *.r01 -or -path *.part01.rar -or -path *.part1.rar | sed -e ’s/ /[SPACE]/g’`
    do
    f=`echo $f | sed -e ’s/\[SPACE\]/ /g’`
    echo $f
    echo `dirname “$f”`
    unrar e -inul “$f” `dirname “$f”`
    done

  4. Gib Wallis:

    Maybe it’s because I’m working with books instead, but this script didn’t work for me.

    I downloaded a lot of RARed public domain books and plays and so now I have a huge number of folders with Chekov, Shakespeare, Shaw, etc.

    When I’m at the top folder for all the authors, this script doesn’t work, but it also doesn’t work when I’m in an individual author’s folder (say, Shakespeare with Shakespeare1.rar Shakespeare2.rar, etc).

    I receive the following response in Terminal:

    1.. Recheck rar (svf check).
    2.. Unrar all.
    3.. Delete rar and sfv files.
    4.. Exit
    Select:

    I choose option 2 and receive this error:

    find: -wholename: unknown option

    Then it loops back to the menu choices again.

    Any suggestions?

  5. Gib Wallis:

    I should also mention I’ve gone into the individual author directories with the same results.

  6. Vladimir Cvetic:

    wholename is standard option of find, seems like your find tool doesn’t support it for some reason.

  7. Robert:

    Hey Vladimir,

    Just wanted to come to say that I still use your script at least three times a week *Two thumbs up*

    Grtz,

    Robert

    PS: Visited Novi-Sad and Belgrade this summer, and I can only say ????? ?? ??????!

    PPS: ?????? ?? ?????? ? ???? ????? ??? ??? ????? ;-)

  8. Robert:

    Ok Cyrillic is not supported :s

  9. Robert:

    Could you please post what the script should look like including the .part01.rar variant?
    I still use (your) unrarr and the version I changed (unrarr2)

  10. braindance:

    Well, on Mac OS X 10.5.7 find -wholename option does not work, I did not find it in man find.

    catohagen’s cycle results in:
    sed: 1: “’s/\n”: invalid command code ?

    Anyone has it working on a Mac?

Leave a Reply