Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Last active Mar 14, 2020
Embed
What would you like to do?
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