Created
November 7, 2025 22:11
-
-
Save kaubu/e25460156e476542c64424a7fa31c130 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $RootFolder = ".\" | |
| $chdFiles = Get-ChildItem -Path $RootFolder -Filter "*.chd" -File | |
| $multiDiscGames = @{} | |
| foreach ($file in $chdFiles) { | |
| if ($file.Name -match '^(.+?)\s+\(Disc\s+\d+\)') { | |
| $gameName = $matches[1] | |
| if (-not $multiDiscGames.ContainsKey($gameName)) { | |
| $multiDiscGames[$gameName] = @() | |
| } | |
| $multiDiscGames[$gameName] += $file | |
| } | |
| } | |
| foreach ($gameName in $multiDiscGames.Keys) { | |
| $folderName = "$gameName.m3u" | |
| $folderPath = Join-Path (Resolve-Path $RootFolder) $folderName | |
| New-Item -Path $folderPath -ItemType Directory -Force | Out-Null | |
| $discFiles = $multiDiscGames[$gameName] | Sort-Object Name | |
| $m3uFilePath = Join-Path $folderPath "$gameName.m3u" | |
| $discFileNames = $discFiles | ForEach-Object { $_.Name } | |
| $discFileNames | Out-File -LiteralPath $m3uFilePath -Encoding ASCII | |
| Write-Host "Created $folderName with $($discFiles.Count) discs" | |
| foreach ($discFile in $discFiles) { | |
| Move-Item -LiteralPath $discFile.FullName -Destination $folderPath | |
| } | |
| } | |
| Write-Host "`nDone! Processed $($multiDiscGames.Count) multi-disc games." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment