winrar command-line help

thegodsend

Junior Member
Feb 13, 2014
7
0
0
im writing a batch file for our FTP server to automatically extract .zip(s) in the morning. However, if the file is corrupt an error will pop up halting the rest of the batch till the winrar message is dealt with. the message has 3 choices. close, Break Operations or copy to clipboard. i was wondering if there are any commands or switches that would be able to close that error if it pops up. I did a rar.exe /? and there is a switch for assuming Yes but if a different error pops up that could cause an issue.

This next question is a noob one but where would i place this switch? Heres the block of code regarding the extraction/deletion of the .zip. I didnt write this part of the batch so this is why i ask

Code:
REM ** Extraction **
for %%i in ("C:\FTP\Happy Sappy\21st\RMFTP*.zip") do "C:\Program Files\WinRAR\winrar.exe" x -o+ "%%i" *.* "C:\FTP\Happy Sappy\21st\" && del "%%i"

REM ** Extraction Check **
for %%i in ("C:\FTP\Happy Sappy\21st\RMFTP*.zip") do echo Error: Extraction issue %%i >> "C:\FTP\! Logs\%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.log"
P.S. I'm using winrar.exe not rar.exe sense rar.exe doesn't work with zip files. the software we use for pushing the files to the server can only compress to zip so rar is not an option.
 
Last edited:

thegodsend

Junior Member
Feb 13, 2014
7
0
0
From the horses mouththough, you want rar.exe, not WinRAR.exe if you want this to have a chance.

P.S. I'm using winrar.exe not rar.exe sense rar.exe doesn't work with zip files. the software we use for pushing the files to the server can only compress to zip so rar is not an option.

Can you use 7-zip instead? Its license is LGPL. Here's its command-line syntax.
I'll take a look into this. There does seem to be exit commands for errors. Thanks.
 

mikeymikec

Lifer
May 19, 2011
20,313
14,977
136
The registered version of winrar gives you a few more command options such as logging at the command prompt.
 
Last edited:

thegodsend

Junior Member
Feb 13, 2014
7
0
0
when chaning the code to use 7zip according to http://sevenzip.sourceforge.jp/chm/cmdline/ it would not work. I'm not sure why.

Here's the code:
Code:
"C:\Program Files\7-Zip\7z" e "D:\FTP\Happy Planet\21st\RMFTP*.zip" *.*
I get this which i >> to a log

Code:
  7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
   
  Processing archive: D:\FTP\Happy Planet\21st\RMFTP 2-13-2014.zip
   
   
  No files to process
   
  Files: 0
  Size:       0
  Compressed: 15962
The files does have some folders and files inside and i have been using this .zip for all my other tests. this is with the main folder is empty (aside from the .zip) encase of an overwrite issue.

The registered version of winrar gives you a few more command options such as logging at the command prompt.

iv already created log commands which really wasn't that hard.
 

thegodsend

Junior Member
Feb 13, 2014
7
0
0
i guess we just want it to hang on the error. for now at least. Thank to those who helped and for anyone doing the same thing u can use the switch "y" to automatically amuse yes on errors for the command.
 
Sep 29, 2004
18,656
67
91
FWIW: You can write a simple java program that would do this. All the zipping/unzipping code is already done for you. Zip files are basically key/value pairs. If the Java program dies, you can catch exceptions and ignore them, if you want. Or you could (and should) use something like Log4j to log errors.

Anyways, I wrote code to deal with zipping and unzipping data once. I was shocked that I actually got it perfect the first time. Usually some detail is missed in code but this was actually that easy.

http://stackoverflow.com/questions/10633595/java-zip-how-to-unzip-folder

This could literally be written in one day by anyone with some professional experience writing Java code. If you have coders in house ask them.

But I still don't know why your company has no license for WinZip. Your company is paying more to have you scratch your head over this.
http://www.winzip.com/order.html#pricing
 
Last edited: