Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One-line for zipping folder in PowerShell?

I'm looking for the equivalent PowerShell command for:

tar -zcvf tar-archive-name.tar.gz source-folder

Does such a one-liner exist that creates a zip file from a folder recursively adding the contents of the source-folder, that doesn't require a 3rd party library like 7-zip?

like image 792
lucidquiet Avatar asked Mar 01 '12 17:03

lucidquiet


1 Answers

Starting with Powershell 5, you can use the built-in Compress-Archive command:

Compress-Archive -Path source-folder -DestinationPath archive-name.zip

If you are using powershell prior to version 5, there is no one liner solution without a third party program like 7-zip. However, you can leverage the built in zipping capabilities of windows explorer as exposed through the COM Shell object to build your own powershell function to do this. This page outlines the details on how to do so.

like image 129
zdan Avatar answered Oct 02 '22 09:10

zdan