Solved

File compression using WINRAR command line utility on Windows Server 2003 machine

Posted on 2011-03-08
5
802 Views
Last Modified: 2013-12-01
I have to write a batch file to use WinRAR cmd line utility which creates an archive in .zip format, which can be opened by any machine without WinRAR. I also need to copy the list of files archived to a .txt file, which will act as a log file for me to see whether the operation was successful or not. I was able to create a .rar file using rar.exe and was able to redirect the output to a .txt file using

"C:\Program Files\WinRAR\rar.exe" a -m5 -ed "c:\Supreeth\resources.rar" "C:\Projects\MyProject\resources" >"c:\Supreeth\log.txt"

However, the resources.rar requires only WinRAR to extract. All the files archived were added in log.txt.
I used
"C:\Program Files\WinRAR\winrar.exe" a -afzip -m5 -ed "c:\Supreeth\resources.zip" "C:\Proje
cts\MyProject\resources" >"C:\Supreeth\log.txt"
The resources.zip file created can be opened by a machine which doesn't have winrar. But, I was not able to log all the files archived.

I want to create a .zip file and log the files archived as well. Please help

0
Comment
Question by:supreeths84
  • 2
5 Comments
 
LVL 3

Expert Comment

by:VespaMaru
ID: 35075034
I haven't used win-rar lately, but 7Zip can do what you want.  It is a Free open source archiver that supports Zip, Rar and many other formats.


C:\Program Files\7-Zip>7z a -tzip -mx5 c:\Supreeth\resources.zip C:\Proje
cts\MyProject\resource > C:\Supreeth\log.txt

This command should work.
7Zip can be found at:
http://sourceforge.net/projects/sevenzip/
0
 

Author Comment

by:supreeths84
ID: 35075078
I was using 7-zip all these days. But the file size grew beyond 6 GB and 7-zip is giving me an error saying "Can't allocate enough memory". So, I was looking for other compression utils and WinRAR was able to compress my file which was more than 6 GB. Can you please help me with this?
0
 
LVL 3

Accepted Solution

by:
VespaMaru earned 500 total points
ID: 35075454
This may be a weird hack, I downloaded WinRAR to test it out, but I can not seem to find a way to get WinRAR to list files or play nice with archives that are not RAR format.  Perhaps you can compress with WinRAR then test the archive with 7Zip.

Example:
start /w "C:\Program Files\WinRAR\winrar.exe" a -afzip -v -m5 -ed c:\Supreeth\resources.zip C:\Projects\MyProject\resource && "C:\Program Files\7-Zip\7z.exe" t  c:\Supreeth\resources.zip > C:\Supreeth\log.txt

Since the archive will already exist, you should be able to avoid the memory allocation issues. You can add " -ilogc:\Supreeth\ErrorLog.txt " if you are worried that WinRAR may encounter an error.
0
 
LVL 27

Expert Comment

by:Tolomir
ID: 35381948
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now