Unrar Multiple Files with Command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unrar Multiple Files with Command
# 1  
Old 09-09-2008
PHP 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.....Smilie
# 2  
Old 09-09-2008
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

# 3  
Old 09-09-2008
Thanks you for your quick response. That works great, it does exactly what I want.... :-)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inputting multiple files into one command

I am trying to read 30 files into a command. The first file contains 10 lines and goes into this part of the command as "x" /tmp/filearrange.sh $x The group of files (20 files, I call them variable $i) need to be the second argument in the command and they need to be read so that they are... (9 Replies)
Discussion started by: newbie2010
9 Replies

2. Shell Programming and Scripting

unrar files

Hi, I have two .rar files on unix server. but how to unrar these files ?? (6 Replies)
Discussion started by: milink
6 Replies

3. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

4. Shell Programming and Scripting

finding multiple files using find command

I am trying to search for 2 files using the find command as below find -name file1.txt -a -name file2.txt It doesn't give a result although the files exist in the folder, however when i try the following find -name file1.txt -o -name file2.txt It does give me the result. ./file2.txt... (4 Replies)
Discussion started by: vivek_damodaran
4 Replies

5. Shell Programming and Scripting

SED command using multiple input files

What is the syntax to use multiple input files in a SED command. i.e. substitute a word with a phrase in every file in a directory. for every file in /usr/include that has the word "date" in the file grep -l '\<date\>' /usr/include/*.h find each occurrence of the word "time" in the file &... (3 Replies)
Discussion started by: sheoguey
3 Replies

6. Shell Programming and Scripting

using mv command for moving multiple files in a folder

Hi, I have a requirement where I need to move Bunch of folders containing multiple files to another archive location. i want to use mv command .I am thinking when we use mv command to move directory does it create directory 1st and then move all the files ? e.g source... (4 Replies)
Discussion started by: rkmbcbs
4 Replies

7. Shell Programming and Scripting

unrar multiple files with password

The problem: how to unrar multiple rar files with known password This works fine: but how to/what to implement to prevent asking me for password each time Have tried: but it wont work. Any help appreciated. (2 Replies)
Discussion started by: vampirex
2 Replies

8. Shell Programming and Scripting

how to use multiple files in sed with w command

i have a command like : sed -n 's/^* /&/w even' <file if i want to write to multiple files like sed -n 's/^* /&/w zero two three' < file its not working it is taking "zero two three" as a single file i want to write to 3 seperate files . pls can anyone help me (2 Replies)
Discussion started by: santosh1234
2 Replies

9. Shell Programming and Scripting

Splitting input files into multiple files through AWK command

Hi, I needs to split *.txt files from single directory depends on the some mutltiple input values. i have wrote the code like below for file in *.txt do grep -i -h "value1|value2" $file > $file; done. My requirment is more input values needs to be given in grep; let us say 50... (3 Replies)
Discussion started by: arund_01
3 Replies

10. UNIX for Dummies Questions & Answers

Perform a command to multiple files

How do I perform a command to multiple files? For example, I want to look at all files in a directory and print the ones that do not contain a certain string. How do I go about doing this? (4 Replies)
Discussion started by: mcgrawa
4 Replies
Login or Register to Ask a Question