-
Notifications
You must be signed in to change notification settings - Fork 2
/
DirectoryToXISO.ps1
70 lines (57 loc) · 2.23 KB
/
DirectoryToXISO.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
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
$DeleteSource = "a"
$SplitXISO = "a"
$TruncateNames = "a"
$Yes = @("Yes", "YES", "yes", "Y", "y")
$No = @("No", "NO", "no", "N", "n")
while(-not($Yes.contains($SplitXISO) -or $No.contains($SplitXISO))) {
$SplitXISO = Read-Host -Prompt "Split XISO? [Y]es or [N]o"
}
while(-not($Yes.contains($TruncateNames) -or $No.contains($TruncateNames))) {
$TruncateNames = Read-Host -Prompt "Truncate Names? [Y]es or [N]o"
}
while(-not($Yes.contains($DeleteSource) -or $No.contains($DeleteSource))) {
$DeleteSource = Read-Host -Prompt "Delete Source? [Y]es or [N]o"
}
$GetSource = New-Object System.Windows.Forms.FolderBrowserDialog
$GetSource.Description = "Select Redump Source Directory"
$GetSource.rootfolder = "MyComputer"
if($GetSource.ShowDialog() -eq "OK"){
$SourceDir = $GetSource.SelectedPath
}
$GetDest = New-Object System.Windows.Forms.FolderBrowserDialog
$GetDest.Description = "Select XISO Destination"
$GetDest.rootfolder = "MyComputer"
if($GetDest.ShowDialog() -eq "OK"){
$DestDir = $GetDest.SelectedPath
}
$Games = Get-ChildItem -Path $SourceDir -Directory
foreach($Game in $Games) {
echo("Converting $Game...")
#Truncate name if selected
$GameName = $Game.Name
if($Yes.contains($TruncateNames) -and $GameName.length -gt 38){
$GameName = $GameName.Substring(0,38)
}
#Create packed XISO and delete source
if($Yes.contains($DeleteSource)) {
./extract-xiso.exe -q -c $SourceDir\$Game $DestDir\$GameName.iso
Remove-Item -R $SourceDir\$Game
}
#Create packed XISO and keep source
else{
./extract-xiso.exe -q -c $SourceDir\$Game $DestDir\$GameName.iso
}
$GameXISO = Get-Item $DestDir\$GameName.iso
#Split XISO if larger than 4GB and truncate name if selected
if($GameXISO.length/1MB -gt 4094 -and $Yes.contains($SplitXISO)){
if($Yes.contains($TruncateNames) -and $GameXISO.BaseName.length -gt 36){
$ShortName = $GameXISO.BaseName.Substring(0,36)
Rename-Item $GameXISO "$ShortName.iso"
$GameXISO = Get-Item("$DestDir\$ShortName.iso")
}
$GameName = $GameXISO.BaseName
./fSplit.exe -split 4094 mb $GameXiso -f "$DestDir\$GameName.{0}.iso"
Remove-Item $GameXiso
}
}