Solved

How do I create a .ZIP archive using rar from the command line?

Posted on 2010-11-15
8
1,111 Views
Last Modified: 2013-12-01
I am automating a process that will zip a folder using rar.  When I use Winrar and choose to create a .ZIP archive manually through the GUI, the files are readable by my client.  When I try to duplicate the process using rar from the command line (in effort to automate this process), even though I name my file with the .ZIP file extension, the files cannot be processed by my client's process.  My client gets a message that says that the file is not a valid zip file.  Is there a trick for creating an authentic .ZIP file using rar at the command line?
0
Comment
Question by:Unity11
8 Comments
 
LVL 5

Expert Comment

by:jcott28
ID: 34138944
winrar a -afzip -r
0
 
LVL 26

Expert Comment

by:pony10us
ID: 34140165
winrar a -afzip -r -ppassword filename.zip directory\*.*

Note that:

Command "a" is to create archive files.
Option "-afzip" is to create archive files in ZIP format.
Option "-r" is to take input files recursively to include sub-directories.
Option "-p*" is to add password protection to archive files.
0
 

Author Comment

by:Unity11
ID: 34140187
Thanks.  I just tried this, but Winrar cannot be run from the command line on our Windows server.  I can only run the RAR.exe from the command line.  So, I really need to know how to create the .ZIP archive using the RAR command line utility.  That's what I was trying to ask originally.  Is this possible?  I know that I can create a .ZIP archive cosmetically (just adding the .ZIP to the file name), but this does not make it a true .ZIP file.  This is what I'm doing right now...

rar a filename.zip sourcefile

This works except for the fact that I am simply masking this as a .ZIP file, but underneath it is really a .RAR file.  Which, my client, cannot accept a .RAR file type.  They need a .ZIP file type.
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 26

Assisted Solution

by:pony10us
pony10us earned 50 total points
ID: 34140215
rar.exe (unlike WinRAR) cannot be used to create a zip archive.

for all possible RAR commands and switches refer to help (rar /?)

0
 
LVL 15

Accepted Solution

by:
Giovanni Heward earned 200 total points
ID: 34140352
You can using the free 7-zip command line @ http://downloads.sourceforge.net/sevenzip/7za465.zip


7za a -tzip archive.zip *.* -mx0

Open in new window

0
 

Author Comment

by:Unity11
ID: 34140643
pony10us: Thanks for breaking down the command line switches and options.  I went ahead and tried using rar with the -afzip switch just to see what would happen.  It actually did allow me to run the command without an error.  Might it actually do what I am hoping?  Does this vary based on the version of rar.exe??  Well, I'll see soon enough. Either way, thank you for the help!

x66_x72_x65_x65: Thank you for the info about the free zip program.  I'll check it out if I can't get rar to work for me.

pony10us: Thanks for providing the command line options quickly.

I will select answers that helped shortly.  Thanks to all
0
 

Author Comment

by:Unity11
ID: 34145982
pony10us: Thought I would just try the rar -afzip option, and you were right.  It doesn't work. Thanks for sharing.

x66_x72_x65_x65: The 7za created a true .ZIP archive.  This is what I needed! Thank you!! :)
0
 
LVL 26

Expert Comment

by:pony10us
ID: 34147500
@Unity11: Glad to be of assistance. I always use either pkzip or winzip for command line compression. I have heard of 7-zip that x66_x72_x65_x65 suggested but not used it.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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