Winrar command line path extraction
Hello everyone,
I created one .bat using winrar command line to convert a file sfx autoexecutable then compresses and then sent by mail using sendemail. But I would like an autoexecutable unpacks in a given file and not in the current directory, and despite my research in the doc, I find nothing. I therefore appeal to you in the hope that one of you knows the solution.
Thank you in advance for your help
Re: Winrar command line path extraction
Follow this steps
1 - make a text file with comments.txt in path = c: \ myaccount \
2 - do your file with your parameters (machin.exe)
3 - winrar to c-zcomment.txt machin.exe
4 - send your mail by machin.exe
Re: Winrar command line path extraction
WINRAR X [ -switches ] <Archive> [ Files ] [ @File lists ] [ Destination folder\ ]
To extract files, ignoring paths:
WINRAR E [ -switches ] <Archive> [ Files ] [ @File lists ] [ Destination folder\ ]
For example if you wish extract the file LETTER.TXT to the current folder from the archive LETTERS.RAR, use the following command:
WINRAR X LETTERS.RAR LETTER.TXT
Archive extension is optional and may be omitted.
The next command extracts all *.WAV files from the archive Songs to the folder Audio:
WINRAR X Songs *.WAV Audio\
It is also possible to list the files to be extracted in a file, rather than listing them on the command line. In this case the name of the file, containing the list of files to be archived, must be given on the command line. This is indicated by placing the symbol @ before this file name. Thus, if you create a file, Binaries, containing the strings *.exe and *.com, execute the command:
WINRAR X TOOLS @Binaries
all files with EXE and COM extensions from the archive TOOLS will be extracted to the current folder.
During the extraction process, a window containing statistics, will be displayed. If you wish to break the extraction process, click on the Cancel button in the command window. You may press the "Background" button in this window to minimize WinRAR to the tray. If extraction is completed, without problems, WinRAR will terminate, in the case of an error, a Diagnostic message window will be displayed.
Re: Winrar command line path extraction
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 Files\WinRAR by default.
Here's an example of how to extract the contents of a single rar file:
1. open a command prompt
(Windows 2000/xp, choose start->programs->accessories->Command Prompt)
2. add the winrar tools to the path:
c:\> set path="C:\Program Files\WinRAR\";%path%
3. switch to the directory where you want your files to extract to:
c:\> cd /d z:\some_folder
4. 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):
Code:
@REM ------- BEGIN demo.cmd ----------------
@setlocal
@echo off
set path="C:\Program Files\WinRAR\";%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 ------------------
Source: respower.com
Re: Winrar command line path extraction
Bravo and thank you
This works perfectly. :thumbup1:
Re: Winrar command line path extraction
Hello everyone,
I have created a batch file to create a winrar sfx archive. What I want to happen is that when the user opens the SFX File, the extraction path is a given directory and not in the current directory. How can i do this using winrar command line?
my command line is:
WinRAR a -r -v4000000 -s -sfx -m5 AUTO
are there any commands to specify the extraction path? thanks!
Re: Winrar command line path extraction
Hello Arvin017,
You need unrar.ext to extract files.
startdir is path where you want to start searching *.rar files.
isodir is path where you want files to get extracted.
Code:
@echo off
@CLS
set startdir=F:\RAR
set isodir=F:\ISOs
setlocal enabledelayedexpansion
@ECHO UNRARer v 0.1
@ECHO (c)2009 Supagusti
@ECHO starting in directory: %startdir%
FOR /F "delims=;" %%G IN ('"dir "%startdir%\*.RAR" /S /B"') DO unrar e "%%G" *.ISO %isodir%
@ECHO finished!
USE *.AVI or *.MP3 to extract avi or mp3 files instead of .iso
Re: Winrar command line path extraction
Re: Winrar command line path extraction
This script works great but how can I add it to automatically overwrite folders and files? I am overwriting every hour and running it in a batch, I don't feel like hitting Yes on every file to overwrite.
Thanks
Jeff