winrar command line to unarchive stuff
Tutorial - Using WinRAR command-line tools
When you install WinRar, two command-line tools are also installed,
rar.exe and unrar.exe. They will be located in C:Program FilesWinRAR by
default.
Here's an example of how to extract the contents of a single rar file:
- open a command prompt
(Windows 2000/xp, choose start->programs->accessories->Command Prompt)
- add the winrar tools to the path:
c:> set path="C:Program FilesWinRAR";%path%
- switch to the directory where you want your files to extract to:
c:> cd /d z:some_folder
- use unrar to extract the file:
z:some_folder> unrar e c:some_rar_file.rar
You can of course wrap all of this into a batch file that loops through
all of the .rar files in a folder. Here's a quicky sample (doesn't
handle spaces in .rar file names):
@REM ------- BEGIN demo.cmd ----------------
@setlocal
@echo off
set path="C:Program FilesWinRAR";%path%
for /F %%i in ('dir /s/b *.rar') do call :do_extract "%%i"
goto :eof
:do_extract
echo %1
mkdir %~1.extracted
pushd %~1.extracted
unrar e %1
popd
REM ------- END demo.cmd ------------------
For detailed information on windows batch files, please see:
OSX documentation [new]
- Open a terminal window.
- In the terminal window, navigate to the folder containing your .rar files:
cd /<path-to-files>
- Run the following command:
for i in *.rar; do unrar e "$i"; done
Note: "unrar" may need to be replaced with the full path to your
unrar executable. For example, if unrar is installed in /usr/local/bin,
the command becomes:
for i in *.rar; do /usr/local/bin/unrar e "$i"; done
OSX unrar is available from RAR Labs,
here
|