Created
September 24, 2020 07:32
-
-
Save eddiezato/a90720e3e5a2202130dbdf77f083a1fb to your computer and use it in GitHub Desktop.
7zip pack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "Archiving:" | |
$start = (Get-Date) | |
For ($i = 0; $i -lt $Args.Count; $i++) { | |
$source = $Args[$i] | |
$type = "file" | |
If (Test-Path -LiteralPath $source -PathType Container) { | |
$source += "\\*" | |
$type = "folder" | |
} | |
$name = (Get-Item -LiteralPath $Args[$i]).Name | |
$current = ($i + 1).ToString().PadLeft($Args.Count.ToString().Length, "0") | |
Write-Host "[$($current)/$($Args.Count)] $($type) " -NoNewLine | |
Write-Host $name -ForegroundColor magenta | |
7z a "$($Args[$i]).zip" "$($source)" -mx7 -mm=Deflate -mfb=128 -bso0 -bsp1 -y | |
If (-not $?) { $Host.UI.RawUI.ReadKey(6) | Out-Null } | |
} | |
$end = (Get-Date) | |
$time = New-TimeSpan -Start $start -End $end | |
Write-Host "Finished in " -NoNewLine | |
Write-Host "$($time.Minutes) m $($time.Seconds) s" -ForegroundColor yellow | |
#$Host.UI.RawUI.ReadKey(6) | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment