Solved

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

Posted on 2010-11-15
8
1,119 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
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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