Join 3,417 readers in helping fund MetaFilter (Hide)


How to unrar lots of rars.
January 29, 2012 9:35 AM   Subscribe

So, I have a whole folder of .rar files. I would like to de-archive all of them, but can't seem to find a way besides clicking them one at a time. I am running Ubuntu, and the only program I've tried so far is the default archive utility program. I haven't been able to find a solution by googling, but maybe my keywords are off. Help me save hours of repetitive clicking!
posted by klugarsh to Computers & Internet (10 answers total)
 
You can't just do an "unrar *.rar" type command?
posted by kellyblah at 9:39 AM on January 29, 2012


Install the unrar package, then do it from the command line.
posted by scruss at 9:40 AM on January 29, 2012


I should mention I'm very new to Ubuntu. Could you possible give me a play by play on the command line thing?
posted by klugarsh at 9:45 AM on January 29, 2012


If you want to do everything under the current directory in a oner:

 find . -type f -iname '*.rar' -exec unrar x -ad {} \;

That will extract them all, preserving folder structure, and putting the contents of each in a folder with the same name as the parent rar file.
posted by scruss at 9:47 AM on January 29, 2012 [2 favorites]


Once you install unrar, it might be slightly more complicated than "unrar *.rar". According the unrar man page, the program only takes on rar file at a time, so you'll have to unpack everything in a loop. Consider:


sudo apt-get install unrar-free
for rarfile in `ls *.rar`; do unrar x $rarfile; done

posted by ayerarcturus at 9:48 AM on January 29, 2012


Note that ayerarcturus's solution won't work if any of the files have spaces in the names.
posted by scruss at 9:50 AM on January 29, 2012


ayerarcturus: the ls isn't required there, btw, you can just do:

for rarfile in *.rar; do unrar x $rarfile; done
posted by jaymzjulian at 10:06 AM on January 29, 2012


Rarzombie is java based and might work for you.
posted by PSB at 10:07 AM on January 29, 2012


Also, because i forgot to preview: you _really" want to write it as:

for rarfile in *.rar; do unrar x "$rarfile"; done

with the quotation marks, or else you'll end up in teh sitaution where a file with spaces or other weird characters will break everything. Or, use the find version above, which takes care of that (which is what my unrar script i use here does)


#!/bin/bash
shopt -s extglob
find !(day*) -mindepth 1 -name '*.rar' -execdir 'rar' '-o-' 'x' '{}' ';'

(the day* thing is to ignore the links created by another script which puts files in folders based on how long ago they were downloaded)
posted by jaymzjulian at 10:08 AM on January 29, 2012


Thanks all! That script worked well and the rarzombie program looks promising for next time as well.
posted by klugarsh at 10:13 AM on January 29, 2012


« Older I want to hang some LP covers ...   |  Some guy told me that the Phil... Newer »
This thread is closed to new comments.