Skip to content

Instantly share code, notes, and snippets.

@phargogh
Created March 10, 2020 17:40
Show Gist options
  • Save phargogh/f17dbad289a45da3f8324bdb8f163878 to your computer and use it in GitHub Desktop.
Save phargogh/f17dbad289a45da3f8324bdb8f163878 to your computer and use it in GitHub Desktop.
Powershell shim for replicating zip -r
# A wrapper around the powershell equivalent of zipping functionality.
# This script takes 3 parameters:
# --> whether to recurse (this is ignored, but we have to take it anyways for compatibility)
# --> The target archive path
# --> The folder to zip.
#
param (
[Parameter(Mandatory=$false, ValueFromPipeline=$false, ParameterSetName='r')]
[switch]
$recurse,
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[String[]]
$target_file,
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[String[]]
$directory
)
# Calling the powershell-equivalent of GNU Zip
Compress-Archive `
-CompressionLevel Optimal `
-DestinationPath "$target_file" `
-Path "$directory"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment