-
Notifications
You must be signed in to change notification settings - Fork 2
/
zipfiles.ps1
25 lines (19 loc) · 843 Bytes
/
zipfiles.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$zipdate = Get-Date -Format('ddMMyyyyHHmm')
$sourcefiles = "PAth\To\Files*"
$newdir = "create\tempdir\to\zip"
$destinationfolder = "\zip\folder\location\and_folder_name_with_zipdate${zipdate}.zip"
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
if((Test-Path $newdir) -eq "True"){
Remove-Item -Recurse -Path $newdir
}else{
New-Item -Path $newdir -ItemType "directory" #-Name "tempdir"
}
Move-Item -Path $sourcefiles -Destination $newdir
function ZipFiles( $zipfilename, $sourcedir )
{
[Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" )
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($newdir, $destinationfolder, $compressionLevel, $false)
}
ZipFiles
Remove-Item -Recurse -Path $newdir