<# .SYNOPSIS Steam App & Manifest Cleanup Utility (del-game) .DESCRIPTION Cleanly removes specified Steam AppID config scripts (.lua), associated manifest files, and game installation directories across all configured Steam library folders. .PARAMETER AppID The Steam Application ID (AppID) to target for cleanup. .EXAMPLE irm https://depotbox.pages.dev/dg | iex .EXAMPLE .\del-game.ps1 -AppID 440 #> [CmdletBinding()] param ( [Parameter(Position=0)] [string]$AppID ) # Helper function for strict y/n prompts function Confirm-Action { param ([string]$Prompt) while ($true) { $response = (Read-Host $Prompt).Trim().ToLower() if ($response -eq 'y') { return $true } if ($response -eq 'n') { return $false } Write-Host " [!] Please enter 'y' or 'n'." -ForegroundColor Yellow } } # Prompt interactively if AppID not supplied via parameter if (-not $AppID) { Write-Host "" $AppID = (Read-Host " ► Enter AppID").Trim() } if ([string]::IsNullOrWhiteSpace($AppID)) { Write-Host " [!] No AppID provided.`n" -ForegroundColor Red return } # 1. Resolve Steam Installation Path $SteamPath = (Get-ItemProperty -Path "HKCU:\Software\Valve\Steam" -ErrorAction SilentlyContinue).SteamPath if (-not $SteamPath) { $SteamPath = "C:\Program Files (x86)\Steam" } $SearchDirs = @( Join-Path $SteamPath "config\lua" Join-Path $SteamPath "config\stplug-in" ) $DepotCacheDirs = @( Join-Path $SteamPath "config\depotcache" Join-Path $SteamPath "depotcache" ) # 2. Locate associated .lua script file $LuaFile = $SearchDirs | ForEach-Object { Join-Path $_ "$AppID.lua" } | Where-Object { Test-Path $_ } | Select-Object -First 1 Write-Host "" Write-Host " ┌── Target : $AppID" -ForegroundColor Cyan if (-not $LuaFile) { Write-Host " └── [!] Script not found in config folders.`n" -ForegroundColor Red return } # 3. Collect matching manifest files from depot cache directories $Pattern = 'setManifestid\s*\(\s*(\d+)\s*,\s*["''"](\d+)["''"]' $TargetManifests = [System.Collections.Generic.List[System.IO.FileInfo]]::new() foreach ($dir in $DepotCacheDirs) { if (Test-Path $dir) { Get-Content $LuaFile | ForEach-Object { if ($_ -match $Pattern) { $ManifestId = $Matches[2] $files = Get-ChildItem -Path $dir -Filter "*$ManifestId*.manifest" -ErrorAction SilentlyContinue if ($files) { $TargetManifests.AddRange($files) } } } } } # 4. Locate Game Installation Directory across all Steam Library Folders $GameDir = $null $GameDirName = $null $LibFoldersFile = Join-Path $SteamPath "steamapps\libraryfolders.vdf" $LibraryPaths = @(Join-Path $SteamPath "steamapps") if (Test-Path $LibFoldersFile) { $content = Get-Content $LibFoldersFile -Raw [regex]::Matches($content, '"path"\s+"([^"]+)"') | ForEach-Object { $libPath = $_.Groups[1].Value -replace '\\\\', '\' $steamAppsPath = Join-Path $libPath "steamapps" if ($steamAppsPath -notin $LibraryPaths -and (Test-Path $steamAppsPath)) { $LibraryPaths += $steamAppsPath } } } foreach ($libPath in $LibraryPaths) { $acfFile = Join-Path $libPath "appmanifest_$AppID.acf" if (Test-Path $acfFile) { $acfContent = Get-Content $acfFile -Raw if ($acfContent -match '"installdir"\s+"([^"]+)"') { $GameDirName = $Matches[1] $candidatePath = Join-Path $libPath "common\$GameDirName" if (Test-Path $candidatePath) { $GameDir = $candidatePath } } break } } # 5. Display Cleanup Plan Write-Host " │ [PLAN]" -ForegroundColor Yellow Write-Host " │ - Config Script : $(Split-Path $LuaFile -Leaf)" -ForegroundColor Gray Write-Host " │ - Manifests : $($TargetManifests.Count) file(s)" -ForegroundColor Gray if ($GameDir) { Write-Host " │ - Game Files : $GameDir" -ForegroundColor Gray } else { Write-Host " │ - Game Files : Not found" -ForegroundColor Gray } Write-Host " │" # 6. Execute Cleanups with User Confirmations Write-Host "" Write-Host " ┌── Executing Clean" -ForegroundColor Cyan # Delete Config Script if (Confirm-Action " ├── [?] Delete config script? (y/n)") { Remove-Item -Path $LuaFile -Force Write-Host " │ [-] Deleted Script : $(Split-Path $LuaFile -Leaf)" -ForegroundColor Green } else { Write-Host " │ [~] Skipped Script" -ForegroundColor DarkGray } # Delete Manifests if ($TargetManifests.Count -gt 0) { if (Confirm-Action " ├── [?] Delete $($TargetManifests.Count) manifest(s)? (y/n)") { foreach ($manifest in $TargetManifests) { Remove-Item -Path $manifest.FullName -Force Write-Host " │ [-] Deleted Manifest: $($manifest.Name)" -ForegroundColor Green } } else { Write-Host " │ [~] Skipped Manifests" -ForegroundColor DarkGray } } else { Write-Host " │ [~] No manifests found" -ForegroundColor DarkGray } # Delete Game Files if ($GameDir) { if (Confirm-Action " ├── [?] Delete game files at '$GameDirName'? (y/n)") { Remove-Item -Path $GameDir -Recurse -Force Write-Host " │ [-] Deleted Game Dir: $GameDirName" -ForegroundColor Green } else { Write-Host " │ [~] Skipped Game Files" -ForegroundColor DarkGray } } else { Write-Host " │ [~] No game directory found" -ForegroundColor DarkGray } Write-Host " └── Done`n" -ForegroundColor Green