Skip to content

Instantly share code, notes, and snippets.

@lukemt
Last active April 30, 2025 12:15
Show Gist options
  • Save lukemt/0bc79febb99a75877fea2afcaaaece6f to your computer and use it in GitHub Desktop.
Save lukemt/0bc79febb99a75877fea2afcaaaece6f to your computer and use it in GitHub Desktop.
zip code
# Deine Paths
$folder = 'D:\pnc\Formsapp'
$archive = 'D:\pnc\FormsappCode.zip'
$sevenZip = 'C:\Program Files\7-Zip\7z.exe' # oder einfach '7z' falls in PATH
$tempFolder = Join-Path $env:TEMP 'FormsappCodeTemp'
# 1. Alten Temp-Ordner löschen (falls vorhanden) und neu anlegen
if (Test-Path $tempFolder) {
Remove-Item $tempFolder -Recurse -Force
}
New-Item -Path $tempFolder -ItemType Directory | Out-Null
# 2. Dateien kopieren (mit Structure) – robocopy filtert nach mehreren Extensions
# /S = include Unterordner, aber keine leeren Ordner
& robocopy $folder $tempFolder *.tcl *.stcl *.ftcl *.py *.ts *.ini *.json *.xml *.sql *.txt /S
# 3. Temp-Ordner zippen
& $sevenZip a -tzip $archive (Join-Path $tempFolder '*')
# 4. Cleanup
Remove-Item $tempFolder -Recurse -Force
Write-Host "Done – all matching files zipped to $archive"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment