Use Powershell and 7-zip to zip up files in a directory individually

Today I needed to put the files I had in a directory into zip files, each one in its own archive. After fiddling around with how to quote and double quote stuff in PoSh I found this link on the technet forums. See Section 5 there.

This is how it’s done:

$arg1…$arg4 are the arguments to 7zip. “a” means add, “-mx3” means fast compression (still a whole lot more effective than zip), $arg2 is the destination archive, $arg3 is the file to be zipped.

Hope this helps.

Leave a Reply

Name *
Email *
Website