Unzip or Unrar files with Batch file?
Moderator: DosItHelp
Unzip or Unrar files with Batch file?
Hi Friends,
Can I unzip or unrar multiple files by creating a batch file?
Plz help me
Can I unzip or unrar multiple files by creating a batch file?
Plz help me
Re: Unzip or Unrar files with Batch file?
Yes, if you use command line unzip and unrar tools.
You need to give more information about where the files currently exist and where the extracted files will go.
Do you know the unzip and unrar command line switches?
You need to give more information about where the files currently exist and where the extracted files will go.
Do you know the unzip and unrar command line switches?
Re: Unzip or Unrar files with Batch file?
There should be a file called "rar.exe" in your %programfiles%\WinRAR folder.
CD (or PUSHD) your DOS window into it and type
It'll return all the command line parameters to you.
Done that, you shall then tell us what exactly you want in your batch file.
CD (or PUSHD) your DOS window into it and type
Code: Select all
rar.exe /?
It'll return all the command line parameters to you.
Done that, you shall then tell us what exactly you want in your batch file.
Re: Unzip or Unrar files with Batch file?
Fawers, Winrar will only be there if the user has installed it, right?
Re: Unzip or Unrar files with Batch file?
foxidrive wrote:Fawers, Winrar will only be there if the user has installed it, right?
I said that assuming he's got it.
Re: Unzip or Unrar files with Batch file?
Fawers wrote:foxidrive wrote:Fawers, Winrar will only be there if the user has installed it, right?
I said that assuming he's got it.
Where did you say that?
Re: Unzip or Unrar files with Batch file?
foxidrive wrote:Fawers wrote:foxidrive wrote:Fawers, Winrar will only be there if the user has installed it, right?
I said that assuming he's got it.
Where did you say that?
I said that:
There should be a file called "rar.exe" in your %programfiles%\WinRAR folder.
CD (or PUSHD) (...)
assuming he has got WinRAR installed already.
to assume (verb)
suppose to be the case, without proof
http://oxforddictionaries.com/definitio ... s&q=assume
Re: Unzip or Unrar files with Batch file?
Fawers wrote:There should be a file called "rar.exe" in your %programfiles%\WinRAR folder.
CD (or PUSHD) your DOS window into it and typeCode: Select all
rar.exe /?
It'll return all the command line parameters to you.
Done that, you shall then tell us what exactly you want in your batch file.
If this is English 101 then please tell me where you used the word 'assuming'?
Re: Unzip or Unrar files with Batch file?
foxidrive wrote:Fawers wrote:There should be a file called "rar.exe" in your %programfiles%\WinRAR folder.
CD (or PUSHD) your DOS window into it and typeCode: Select all
rar.exe /?
It'll return all the command line parameters to you.
Done that, you shall then tell us what exactly you want in your batch file.
If this is English 101 then please tell me where you used the word 'assuming'?
Oh god.
Look, mate,
I really don't want to flood - or keep flooding - the forum like this.
It is not my fault if your individual understanding skills are not good.
I don't have to say that I'm assuming something1 = something2 for people to understand that what I am doing is, in fact, assuming.
Besides, none of us is helping our fellow here with his problem.
But ok. Assuming our fellow has got WinRAR installed on his HD, and assuming he has checked "rar.exe" command line parameters already, what would the next step be?
Re: Unzip or Unrar files with Batch file?
You can help him mate.
You were so anal when all you had to say was 'Oh, I wasn't very clear, was I?.
Now that you have a dictionary, look up the word 'ego'. Try and reduce yours a few notches.
You were so anal when all you had to say was 'Oh, I wasn't very clear, was I?.
Now that you have a dictionary, look up the word 'ego'. Try and reduce yours a few notches.
Re: Unzip or Unrar files with Batch file?
Tested:
Code: Select all
@echo off
set rarpath=
::rarpath should contain the full - or short - path of rar.exe file inside WinRAR folder
::assuming you've got WinRAR, of course
::place this batch file in the same folder as your .rar files
::files will be extracted into this same folder
::WinRAR command line works well with .rar files, but not with .zip files
:EXTRACT
if exist *.rar (
"%rarpath%" e *.rar
>nul pause
) else (
for %%d in ("%cd%") do echo No .rar files were found in "%%~nd".
)
Last edited by Fawers on 12 Apr 2012 11:18, edited 3 times in total.
Re: Unzip or Unrar files with Batch file?
foxidrive wrote:You were so anal when all you had to say was 'Oh, I wasn't very clear, was I?.
foxidrive wrote:If this is English 101 then please tell me where you used the word 'assuming'?
All I had to say was that. And all you had to say was, "Oh, you assumed it, didn't you?".
Oh, the irony.
Was all that really necessary?
I'm finished with the flooding.
Re: Unzip or Unrar files with Batch file?
I figured a way to unzip files with batch.
On my previous code, I couldn't help but notice that it wouldn't unzip files; it will only unrar them.
Do you have 7zip? If you don't, look forward to downloading it, for it has too a command line based file named "7z.exe".
I tested it and it works both with .7z and .zip files. In essence, we can have one batch script to extract .7z, .rar and .zip files.
I'll start writing the code, and will post it here later.
7-Zip download page
On my previous code, I couldn't help but notice that it wouldn't unzip files; it will only unrar them.
Do you have 7zip? If you don't, look forward to downloading it, for it has too a command line based file named "7z.exe".
I tested it and it works both with .7z and .zip files. In essence, we can have one batch script to extract .7z, .rar and .zip files.
I'll start writing the code, and will post it here later.
7-Zip download page
Re: Unzip or Unrar files with Batch file?
Fawers wrote:Was all that really necessary?
It's customary to mention dependencies on external packages, even more so in the case of "paid for" ones such as WinRAR.
FWIW there is also the completely free and standalone unrar.exe (http://www.rarlab.com/rar_add.htm) which requires no money, no installation, and has its source code available.
Fawers wrote:Do you have 7zip? If you don't, look forward to downloading it, for it has too a command line based file named "7z.exe".
7z.exe requires 7z.dll too. The self-contained 7za.exe (in the 'extra' package at http://sourceforge.net/projects/sevenzi ... -Zip/9.22/) supports fewer formats natively, including 7z and zip, but not rar.
Liviu
Re: Unzip or Unrar files with Batch file?
Liviu wrote:FWIW there is also the completely free and standalone unrar.exe (http://www.rarlab.com/rar_add.htm) which requires no money, no installation, and has its source code available.
But does it support command line operations?
7z.exe requires 7z.dll too. The self-contained 7za.exe (in the 'extra' package at http://sourceforge.net/projects/sevenzi ... -Zip/9.22/) supports fewer formats natively, including 7z and zip, but not rar.
I think the standard 7zip installation file comes with 7z.dll already. At least I have it here in 7-Zip folder, and I can't remember of downloading any additional patch/update. I don't have 7za.exe, though.