The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
unrar on MPRAS (UNIX) Mr C UNIX for Dummies Questions & Answers 0 07-20-2008 09:36 PM
Splitting input files into multiple files through AWK command arund_01 Shell Programming and Scripting 3 05-13-2008 06:17 AM
how to rename multiple files with a single command tayyabq8 Shell Programming and Scripting 5 03-18-2008 01:04 PM
Command line tool to join multiple .wmv files? karman OS X (Apple) 2 09-22-2007 10:52 PM
Perform a command to multiple files mcgrawa UNIX for Dummies Questions & Answers 4 09-25-2003 01:40 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-09-2008
Registered User
 

Join Date: Sep 2008
Posts: 4
Thumbs down Unrar Multiple Files with Command

I work with multiple archive files, mostly rar. I understand the basics of rar and zip. I'm looking for a way to decompress multiple rar files with a single command. Hopefully each file would be unrared into dir with same name as archive. I normally just do this manually, but sometimes I'm processing up to 30 or more files at a time. So a streamlining process would be helpful. Yesterday, in a Suse linux forum I saw a command that works great with zip:
Quote:
for i in *.zip
do
mkdir "${i/.zip}"
unzip -d "${i/.zip}" "$i"
done
I tried it out with some zip files. It works great, Creates individual dirs and unzips files into them. It processed 6 zip files in a few seconds. Manually it would have taken me several minutes.
However, I normally work with Rar files so I tried to adapt this command, but I can't get it right. This is what I used:
Quote:
for i in *.rar
do
mkdir "${i/.rar}"
unrar e "${i/.rar}" "$i"
done
It creates the directories but doesn't unrar files into them. I know I'm overlooking something very basic. But with my limited skills using the command line I've not found a working command. I'd appreciate some help.....
Reply With Quote
Forum Sponsor
  #2  
Old 09-09-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 920
unrar e extracts files to the current directory, not one specified on the unrar command-line.

Try this:

Code:
for i in *.rar
do
  mkdir "${i/.rar}"
  cd "${i/.rar}"
  unrar e "../$i"
  cd ..
done
Reply With Quote
  #3  
Old 09-09-2008
Registered User
 

Join Date: Sep 2008
Posts: 4
Thanks you for your quick response. That works great, it does exactly what I want.... :-)
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0