Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Unrar Multiple Files with Command Post 302234480 by Annihilannic on Tuesday 9th of September 2008 08:00:09 PM
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

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
RAR_OPEN(3)								 1							       RAR_OPEN(3)

RarArchive::open - Open RAR archive

       Object oriented style (method):

SYNOPSIS
publicstatic RarArchive RarArchive::open (string $filename, [string $password = NULL], [callable $volume_callback = NULL]) DESCRIPTION
Procedural style: RarArchive rar_open (string $filename, [string $password = NULL], [callable $volume_callback = NULL]) Open specified RAR archive and return RarArchive instance representing it. Note If opening a multi-volume archive, the path of the first volume should be passed as the first parameter. Otherwise, not all files will be shown. This is by design. PARAMETERS
o $filename - Path to the Rar archive. o $password - A plain password, if needed to decrypt the headers. It will also be used by default if encrypted files are found. Note that the files may have different passwords in respect to the headers and among them. o $volume_callback - A function that receives one parameter - the path of the volume that was not found - and returns a string with the correct path for such volume or NULL if such volume does not exist or is not known. The programmer should ensure the passed function doesn't cause loops as this function is called repeatedly if the path returned in a previous call did not correspond to the needed volume. Specifying this parameter omits the notice that would otherwise be emitted whenever a volume is not found; an implementation that only returns NULL can therefore be used to merely omit such notices. Warning Prior to version 2.0.0, this function would not handle relative paths correctly. Use realpath(3) as a workaround. RETURN VALUES
Returns the requested RarArchive instance or FALSE on failure. CHANGELOG
+--------+-----------------------------+ |Version | | | | | | | Description | | | | +--------+-----------------------------+ | 3.0.0 | | | | | | | $volume_callback was added. | | | | +--------+-----------------------------+ EXAMPLES
Example #1 Object oriented style <?php $rar_arch = RarArchive::open('encrypted_headers.rar', 'samplepassword'); if ($rar_arch === FALSE) die("Failed opening file"); $entries = $rar_arch->getEntries(); if ($entries === FALSE) die("Failed fetching entries"); echo "Found " . count($entries) . " files. "; if (empty($entries)) die("No valid entries found."); $stream = reset($entries)->getStream(); if ($stream === FALSE) die("Failed opening first file"); $rar_arch->close(); echo "Content of first one follows: "; echo stream_get_contents($stream); fclose($stream); ?> The above example will output something similar to: Found 2 files. Content of first one follows: Encrypted file 1 contents. Example #2 Procedural style <?php $rar_arch = rar_open('encrypted_headers.rar', 'samplepassword'); if ($rar_arch === FALSE) die("Failed opening file"); $entries = rar_list($rar_arch); if ($entries === FALSE) die("Failed fetching entries"); echo "Found " . count($entries) . " files. "; if (empty($entries)) die("No valid entries found."); $stream = reset($entries)->getStream(); if ($stream === FALSE) die("Failed opening first file"); rar_close($rar_arch); echo "Content of first one follows: "; echo stream_get_contents($stream); fclose($stream); ?> Example #3 Volume Callback <?php /* In this example, there's a volume named multi_broken.part1.rar * whose next volume is named multi.part2.rar */ function resolve($vol) { if (preg_match('/_broken/', $vol)) return str_replace('_broken', '', $vol); else return null; } $rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar', null, 'resolve'); $entry = $rar_file1->getEntry('file2.txt'); $entry->extract(null, dirname(__FILE__) . "/temp_file2.txt"); ?> SEE ALSO
rar:// wrapper. PHP Documentation Group RAR_OPEN(3)
All times are GMT -4. The time now is 05:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy