Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Last active March 14, 2020 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BananaAcid/af2afa89c086de210c2fd647335b80f0 to your computer and use it in GitHub Desktop.
Save BananaAcid/af2afa89c086de210c2fd647335b80f0 to your computer and use it in GitHub Desktop.
compress a folder with 7z using a gitignore list
node_modules
.git
.gitignore
# the resulting file will be like name_2019-12-01.7z
Function Pack-Folder {
param($name, $folder, $ignoreFile=".gitignore", $useDate=$true)
$dStr;
if ($notUseDate) {
$dStr = "_$(Get-Date -UFormat %Y-%m-%d)"
}
else {
$dStr = ""
}
7z.exe a -t7z "$($name)$($dStr).7z" "$($folder)" -bd -mx9 -xr@"$($ignoreFile)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment