-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDD_Create_and_Split.ps1
43 lines (34 loc) · 1.45 KB
/
DD_Create_and_Split.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
$DeleteSource = "a"
$ExpandArchives = "a"
$Yes = @("Yes", "YES", "yes", "Y", "y")
$No = @("No", "NO", "no", "N", "n")
while(-not($Yes.contains($ExpandArchives) -or $No.contains($ExpandArchives))) {
$ExpandArchives = Read-Host -Prompt "Find and expand ZIP archives to Games folder? [Y]es or [N]o"
}
while(-not($Yes.contains($DeleteSource) -or $No.contains($DeleteSource))) {
$DeleteSource = Read-Host -Prompt "Delete Source ISOs after processing? [Y]es or [N]o"
}
if($Yes.contains($ExpandArchives)) {
$Zips = Get-ChildItem -Path 'Games' -Filter *.zip -Recurse
foreach($zip in $Zips) {
write-output "Trying to expand archive: $($zip.FullName)"
Expand-Archive -LiteralPath $zip.FullName -DestinationPath "Games" -Force
}
}
$Games = Get-ChildItem -Path 'Games' -Filter *.iso
foreach($Game in $Games) {
$GameName = $Game.BaseName -replace ('[=\?:;"\*\+,\|]', '_')
$GameName = $GameName.Substring(0, $GameName.IndexOf("(")).Trim()
write-output "Processing '$Game' as '$GameName'"
if($GameName.length -gt 36) {
$GameName = $Game.Name.Substring(0,36)
write-output "Truncating filename to: $GameName"
}
$GameDD = "Games\" + $GameName + "_DD.iso"
& "$PSScriptRoot\dd.exe" @("if=Games\$Game", "of=$GameDD", "skip=387", "bs=1M")
& "$PSScriptRoot\fSplit.exe" @('-split', 4032, 'mb', $GameDD, '-df', 'Games', '-f', "$GameName.{0}.iso")
Remove-Item $GameDD
if($Yes.contains($DeleteSource)) {
Remove-Item Games\$Game
}
}