SCRIPTS TO EXTRACT AND ORGANIZE YOUR RAR FILES
#############################################
#############################################

UPDATE 04-28-2015: latest scripts for unrar (and also unzip version) located over here: unrar123 & unzip scripts


Good if you torrent. Not that I do, I dont even know what that is.

This works great on rar files that are split into volumes as well (meaning rar files that are split into many rar files, such as rar, r01, r02, etc).

INTERESTING NOTE IF YOU DONT WANT TO EXTRACT THEM: you can watch RARed up movies (even if multiple rar files) from VLC. Also you can mount RAR files as mount points with linux. Or you can pull individual files from the RAR files.

Here I will show you how to extract multiple rar files scattered in multiple directories. Kind of like the way your folders look after doing some downloads.

STEP1)

Get the correct rar tool first

DONT USE unrar-free – the best rar tool you have to download and install using below method

Go here: http://www.rarlab.com/download.htm and find the latest linux version (one thats 64bit or the none 64 bit one). Im going to use the 64 bit one.

At my time the latest one is:http://www.rarlab.com/rar/rarlinux-x64-5.1.0.tar.gz

NOTE: the unrar file should just work right there without compiling. ./unrar to use it. But lets install it (meaning copy its contents to $PATH type of directories, using its built in install)

NOTE: if above fails type “apt-get upate && apt-get install build-essential”

NOTE: to uninstall look at the makefile and look at the files and the locations they get copied to, then just erase those files manually. these files are so small and insignificant that uninstalling shouldnt really be that important to you. the install of unrar shouldnt hurt a soul (besides that of unrar-free)

NOTE: if you accidentaly do already have unrar-free. Uninstall it like so:  apt-get remove unrar-free && hash -r  the hash -r part unties unrar from unrar-free’s unrar file

STEP2)

Check out how many rar files your dealing with (we dont care about the .rXX ones, just the .rar, so we can see how many rar sets we are dealing with)

Now we can go on to extracting

This method will extract each rar file in its own folder. It will find multiple rar files such as .r01 and etc automatically.

NOTE: in examples below my SOURCE variable is the location where all of the rars are at (and I change it up from /downloads to other names, because I was doing my own testing and my rar files arent in a location called /downloads)

The above tells you how many rar files there are to extract (the nl will number them out)

STEP3) Pick a script and run it (3 scripts below to choose from. My favorite is script 2 or 3)

##########################################
SCRIPT1 – mass rar extract to original folders (messy)
##########################################

pro: less folders
con: rars mixed with extracted stuff

The below script will extract each rar file into its current directory (the rars will make whatever subdirectories they need to make – which ever ones they contain of course).

Here is a visual example of what it will do

Imagine the following rar files:

In above example I would choose
SOURCE=/Downloads

NOTE: you will need to get rid of the rar files afterwards for cleanup

NOTE: Don’t forget to set the SOURCE variable (or comment the SOURCE= line and the cd $source line and just copy paste below script into your bash, to unrar recursively in the current working directory)

##############################################
SCRIPT2 – mass rar extract to original folder, but also make _extracted folder in there
##############################################

pro: more organized, everything is together
con: annoying extra _extracted folder

The below script will extract each rar file into its current directory within a special _extracted folder in each directory for extra organization (the rars will make whatever subdirectories they need to make – which ever ones they contain of course).

Imagine the following rar files:

It will extract like so:

The % represents the extracted rar content, without any of the rar files

In above example I would choose
SOURCE=/Downloads

NOTE: Don’t forget to set the SOURCE variable (or comment the SOURCE= line and the cd $source line and just copy paste below script into your bash, to unrar recursively in the current working directory)

####################################################
SCRIPT3 – mass rar extract to segregated folder keeping directory structure (clean)
####################################################

pro: cleaners, looks betters. rars in one folder set, extracted stuff in another
con: more foldres

For the best seperation of extracted and none extracted stuff. Check out this method. It will extract all rar files into /extractdir but maintain the name of the paths. So its like making a directory tree copy except now all of the rar files will be in /downloads, and the /extractdir will have all of the extracted stuff

Here is a visual example of what it will do

Imagine the following rar files:

And it will extract to this:

The % represents the extracted rar content, without any of the rar files

In above example I would choose
SOURCE=/Downloads
DESTINATION=/Downloads-Extracted/

NOTE: Don’t forget to set the SOURCE variable (or comment the SOURCE= line and the cd $source line and just copy paste below script into your bash, to unrar recursively in the current working directory)

  ALL SCRIPTS MADE INTO EXECUTABLE SCRIPT

– the above are more of copy pasteables (where you edit the source and destination)

– the below are more of scripts, that are run from command line. They will look for rar files from current folder down recursively. Only the 3rd script needs an argument (to tell it where to extract the folders)

– keep in mind each of the 3 scripts does unrar into different folder differently (pick which ever one you need for the job). I can find it that at different times different ones are useful.

 

LATEST UNRAR SCRIPTS BELOW

Update happened on 2015-01-18: latest versions of all 3 unrar scripts are below (actually now there are 6 unrar scripts, each one has an extra variation, more info below) – please read the comments below to see the new changes and details about all of the scripts. The scripts have went under many improvements & changes from the above scripts in the article, to make them better to use and fix errors. Also shows stats.

SIDENOTE ABOUT THE SCRIPTS THAT DELETE THE RARS AFTER SUCCESSFUL EXTRACTION: Use unrar2extracted-delete-rars.sh rather that the unrar1 or 3 version of *delete-rars.sh. unrar2 algorithm just handles it better than unrar1 and unrar3 when deleting the rar files after successful deletion – more on it below in the comments.

 

2 thoughts on “UNRAR123 – UNRAR Recursively – my unrar tools – good for downloads of rars (works with split volumes)

Leave a Reply

Your email address will not be published. Required fields are marked *