Quantcast
Viewing all articles
Browse latest Browse all 14

Answer by Beaner for Can you zip a file from the command prompt using ONLY Windows' built-in capability to zip files?

If you are open to using PowerShell, zip capabilities are available in .NET 2.0 (PowerShell is .NET). Here's an a example (source) credit to Mike Hodnick:

######################################################### out-zip.ps1## Usage:#    To zip up some files:#       ls c:\source\*.txt | out-zip c:\target\archive.zip $_##    To zip up a folder:#       gi c:\source | out-zip c:\target\archive.zip $_########################################################$path = $args[0]$files = $inputif (-not $path.EndsWith('.zip')) {$path += '.zip'} if (-not (test-path $path)) {   set-content $path ("PK"+ [char]5 + [char]6 + ("$([char]0)" * 18)) } $ZipFile = (new-object -com shell.application).NameSpace($path) $files | foreach {$zipfile.CopyHere($_.fullname)}

Viewing all articles
Browse latest Browse all 14

Trending Articles