Solved

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

Posted on 2010-11-15
8
1,070 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
Comment Utility
winrar a -afzip -r
0
 
LVL 26

Expert Comment

by:pony10us
Comment Utility
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
Comment Utility
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
 
LVL 26

Assisted Solution

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

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

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 14

Accepted Solution

by:
Giovanni Heward earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
@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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

8 Experts available now in Live!

Get 1:1 Help Now