?
Solved

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

Posted on 2010-11-15
8
Medium Priority
?
1,126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 26

Assisted Solution

by:pony10us
pony10us earned 200 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 800 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 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