Created
August 2, 2026 02:14
-
-
Save kickbase/4820c73e2fa2245444cc09027ee4ee65 to your computer and use it in GitHub Desktop.
[Houdini] Remove all "backup" folders under RootPath
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
| # Remove all "backup" folders under RootPath (ASCII only - no encoding issues) | |
| $RootPath = $PSScriptRoot | |
| try { | |
| if (-not (Test-Path -Path $RootPath -PathType Container)) { | |
| Write-Host "Error: Path not found. [$RootPath]" -ForegroundColor Red | |
| exit 1 | |
| } | |
| $backups = @(Get-ChildItem -Path $RootPath -Recurse -Directory -Filter "backup" -ErrorAction SilentlyContinue) | |
| if ($backups.Count -eq 0) { | |
| Write-Host "[$RootPath] No backup folder(s) found." -ForegroundColor Yellow | |
| } else { | |
| $backups | Remove-Item -Recurse -Force -ErrorAction Stop | |
| Write-Host "[$RootPath] Removed $($backups.Count) backup folder(s)." -ForegroundColor Green | |
| } | |
| } catch { | |
| Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment