• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1142
  • Last Modified:

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

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
Unity11
Asked:
Unity11
2 Solutions
 
jcott28Commented:
winrar a -afzip -r
0
 
pony10usCommented:
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
 
Unity11Author Commented:
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
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
pony10usCommented:
rar.exe (unlike WinRAR) cannot be used to create a zip archive.

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

0
 
Giovanni HewardCommented:
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
 
Unity11Author Commented:
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
 
Unity11Author Commented:
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
 
pony10usCommented:
@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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now