forked from towerwatchman/Atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_package.bat
More file actions
29 lines (26 loc) · 1.08 KB
/
Copy pathcreate_package.bat
File metadata and controls
29 lines (26 loc) · 1.08 KB
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
26
27
28
29
@echo off
setlocal
set "OUTPUT=project_backup.zip"
if exist "%OUTPUT%" del "%OUTPUT%"
powershell -NoProfile -Command ^
"$exclude = @('dist','node_modules', 'data');" ^
"$root = Get-Location;" ^
"$files = Get-ChildItem -Path $root -Recurse -File | Where-Object {" ^
" $rel = $_.FullName.Substring($root.Path.Length).TrimStart('\');" ^
" $parts = $rel -split '\\';" ^
" -not ($parts | Where-Object { $exclude -contains $_ })" ^
"};" ^
"if (Test-Path '%OUTPUT%') { Remove-Item '%OUTPUT%' }" ^
"foreach ($f in $files) {" ^
" $rel = $f.FullName.Substring($root.Path.Length).TrimStart('\');" ^
" Add-Type -AssemblyName System.IO.Compression.FileSystem | Out-Null;" ^
"}" ^
"$zip = [System.IO.Compression.ZipFile]::Open((Join-Path $root '%OUTPUT%'), 'Create');" ^
"foreach ($f in $files) {" ^
" $rel = $f.FullName.Substring($root.Path.Length).TrimStart('\');" ^
" [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $f.FullName, $rel) | Out-Null;" ^
"}" ^
"$zip.Dispose();" ^
"Write-Host 'Created %OUTPUT% with' $files.Count 'files.'"
echo Done.
pause