Update zip-dir.ps1

This commit is contained in:
Markus Fleschutz 2021-08-27 19:39:48 +02:00
parent 503a7485f1
commit 4b923a2d75
3 changed files with 10 additions and 8 deletions

View File

@ -244,4 +244,4 @@ write-rot13.ps1, encodes or decodes the given text with ROT13
write-typewriter.ps1, writes the given text with the typewriter effect
write-uppercase.ps1, writes the given text in uppercase letters
write-vertical.ps1, writes the given text in vertical direction
zip-dir.ps1, creates a zip archive of the given directory
zip-dir.ps1, creates a .zip archive of the given directory

Can't render this file because it has a wrong number of fields in line 85.

View File

@ -158,7 +158,7 @@ Mega Collection of PowerShell Scripts
* [SHA1.ps1](Scripts/SHA1.ps1) - prints the SHA1 checksum of the given file
* [SHA256.ps1](Scripts/SHA256.ps1) - prints the SHA256 checksum of the given file
* [upload-file.ps1](Scripts/zip-dir.ps1) - uploads the local file to the given FTP server
* [zip-dir.ps1](Scripts/zip-dir.ps1) - creates a zip archive of the given directory
* [zip-dir.ps1](Scripts/zip-dir.ps1) - creates a .zip archive of the given directory
📝 Scripts for Git
-------------------

View File

@ -2,7 +2,7 @@
.SYNOPSIS
zip-dir.ps1 [<directory>]
.DESCRIPTION
Creates a zip archive of the given directory
Creates a .zip archive of the given directory
.EXAMPLE
PS> .\zip-dir.ps1 C:\Windows
.LINK
@ -12,15 +12,17 @@
License: CC0
#>
param([string]$Directory = "")
param([string]$directory = "")
try {
if ($Directory -eq "" ) { $Directory = read-host "Enter the path to the directory to zip" }
if ($directory -eq "" ) { $directory = read-host "Enter the path to the directory to zip" }
$StopWatch = [system.diagnostics.stopwatch]::startNew()
$Directory = resolve-path $Directory
compress-archive -path $Directory -destinationPath $Directory.zip
$directory = resolve-path $directory
compress-archive -path $directory -destinationPath $directory.zip
"✔️ created zip archive: $($Directory).zip"
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ created zip archive: $($directory).zip in $Elapsed sec"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"