-
Notifications
You must be signed in to change notification settings - Fork 1
/
find_missing_games.ps1
79 lines (50 loc) · 2.24 KB
/
find_missing_games.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
75
76
77
78
79
# root
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$whdloadGameSlaveIndexPath = [System.IO.Path]::Combine($scriptPath, "whdownload_games\whdownload_games_index.csv")
$whdloadInstallSlaveIndexPath = [System.IO.Path]::Combine($scriptPath, "whdload_installs\whdload_installs_index.csv")
# simplify name by removing "the" word, special characters and converting roman numbers
function SimplifyName($name)
{
return $name -replace "[\(\)\&,_\-!':]", " " -replace "the", "" -replace "[-_ ]vii", " 7 " -replace "[-_ ]vi", " 6 " -replace "[-_ ]v", " 5 " -replace "[-_ ]iv", " 4 " -replace "[-_ ]iii", " 3 " -replace "[-_ ]ii", " 2 " -replace "[-_ ]i", " 1 " -replace "\s+", " "
}
# make comparable name by simplifying name, removing whitespaces and non-word characters
function MakeComparableName($name)
{
return ((SimplifyName $name) -replace "\s+", "" -replace "[^\w]", "").ToLower()
}
# read whdload slave index
function ReadWhdloadSlaveIndex($whdloadSlaveIndexFile)
{
$index = @{}
ForEach($line in (Get-Content $whdloadSlaveIndexFile | Select-Object -Skip 1))
{
$columns = $line -split ";"
$name = MakeComparableName (([System.IO.Path]::GetFileNameWithoutExtension($columns[0])) -split '_' | Select-Object -First 1 )
#$name = MakeComparableName $columns[1]
$item = $index.Get_Item($name)
if (!$item)
{
$item = @()
}
$item += , $columns
$index.Set_Item($name, $item)
}
return $index
}
# Read whdload games index
Write-Output "Reading whdload game slave index file '$whdloadGameSlaveIndexPath'..."
$whdloadGameSlaves = ReadWhdloadSlaveIndex $whdloadGameSlaveIndexPath
$whdloadGameSlaves.Count
Write-Output "Reading whdload install slave index file '$whdloadInstallSlaveIndexPath'..."
$whdloadInstallSlaves = ReadWhdloadSlaveIndex $whdloadInstallSlaveIndexPath
$whdloadInstallSlaves.Count
# 13. Process whdload game files
ForEach ($whdloadInstallSlaveName in $whdloadInstallSlaves.Keys)
{
$whdloadGameSlave = $whdloadGameSlaves.Get_Item($whdloadInstallSlaveName)
if (!$whdloadGameSlave)
{
#Write-Output $whdloadInstallSlaveName
}
}
$whdloadInstallSlaves.Keys | where { !$whdloadGameSlaves.ContainsKey($_) } | Sort-Object