Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have several RAR archives spread around multiple directories but all under a particular root folder on my Debian based NAS. Could someone help me write a simple script that would recursively go into each folder, unrar the contents, go back to the parent folder and move onto the next directory? So:

cd Photos/Summer/Italy/
unrar e Italy.rar
cd ../France/
unrar e France.rar

So just point it to root folder "Photos" and it blitzes through it unraring everything on the way...

Eg, directory structure:

share|improve this question
up vote 11 down vote accepted
find Photos/ -name '*.rar' -execdir unrar e {} \; 
share|improve this answer
Brilliant, didn't know it was so easy! Thank you very much! – Touff Apr 16 '12 at 23:17

If you want to move the unrar'd photos to another destination, just enter the destination in the end, like this:

find source_dir/ -name '*.rar' -execdir unrar e -o- {} /new/destination_dir/ \;

share|improve this answer

unrar has built-in recursion using the -r Recurse subdirectories switch.

unrar x -r <parent directory> Extracts contents of all subdirectories under <parent directory> into each subdirectory, keeping any directory structure that exists in the .rar files. Use e instead of x if directory structure is unwanted.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .