forked from Ryex/Dungeondraft-GoPackager
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FA_Repacker.ps1
74 lines (60 loc) · 2.47 KB
/
FA_Repacker.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
param([string]$Output="", [switch]$Clean)
$Path = (Get-Location).Path
if ($Output == "") {
$Output = $Path
}
$Path = (Get-Location).Path
$startTime = Get-Date
cd $Path
#$areas = "Roofs"
$areas = "Assets", "Textures_Natural", "Textures_Artificial", "Legacy", "Roof_Patterns", "Roofs"
foreach ($currentFocus in $areas) {
#$currentFocus = "Textures_Artificial"
$packPrefix = "FA_$($currentFocus)_REPACK_"
$packName = "$packPrefix$((Get-Date).ToString("MM-dd-yy"))"
$joinedPath = "$($Path)\$($currentFocus)\joined"
Get-ChildItem -Filter "*$currentFocus*" |
Select-Object -ExpandProperty Name |
% {
.\dungeondraft-unpack.exe -O -vv $_ "$currentFocus\unpacked"
}
cd "$currentFocus"
New-Item -Path 'joined' -ItemType Directory -Force
cd "unpacked"
$firstDir = Get-ChildItem -Directory | select -First 1 -ExpandProperty Name
cd $firstDir
$manifest = Get-Content 'pack.json' | Out-String | ConvertFrom-Json
#$manifest.name = $packName
#$manifest.version = (Get-Date).ToString("MMddyy")
#$manifest.id = "FA$manifest"
#$manifest | ConvertTo-Json -depth 100 | Out-File "$joinedPath\pack.json" -Force
Get-ChildItem -Filter "preview.png" | Move-Item -Destination $joinedPath -Force
cd ..
Get-ChildItem -Directory |
select -ExpandProperty Name |
% {
$ogName = $_
cd $_
Get-ChildItem -Directory |
select -ExpandProperty Name |
% {
$sourcePath = "$($Path)\$($currentFocus)\unpacked\$($ogName)\$($_)\"
$sourceFolder = (new-object -com shell.application).NameSpace($sourcePath)
$destinationFolder = (new-object -com shell.application).NameSpace($joinedPath)
$destinationFolder.MoveHere($sourceFolder,16)
}
cd ..
}
cd ..
Get-ChildItem -Directory -Filter "unpacked" | Remove-Item -force -recurse
cd ..
# Remove older repacks:
Get-ChildItem -File -Filter "$packPrefix*" | Remove-Item -Force
.\dungeondraft-pack.exe -O -E -A $manifest.author -N $packName -V $((Get-Date).ToString("MMddyy")) $joinedPath $Output
Get-ChildItem -Directory -Filter $currentFocus | Remove-Item -force -recurse
if ($Clean) {
Get-ChildItem -Filter -File "*$currentFocus*" | Remove-Item -force -recurse
}
Write-Output "Start Time: $startTime"
Get-Date | Write-Output "End Time: $_"
}