-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclean.ps1
More file actions
42 lines (34 loc) · 1.43 KB
/
clean.ps1
File metadata and controls
42 lines (34 loc) · 1.43 KB
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
#!/usr/bin/env pwsh
# Clean script to remove all bin/ and obj/ directories recursively
Write-Host "🧹 Cleaning all bin/ and obj/ directories..." -ForegroundColor Cyan
# Get all bin and obj directories recursively
$binDirs = Get-ChildItem -Path . -Recurse -Directory -Name "bin" -Force
$objDirs = Get-ChildItem -Path . -Recurse -Directory -Name "obj" -Force
$totalDirs = $binDirs.Count + $objDirs.Count
if ($totalDirs -eq 0) {
Write-Host "✅ No bin/ or obj/ directories found. Already clean!" -ForegroundColor Green
exit 0
}
Write-Host "Found $($binDirs.Count) bin/ and $($objDirs.Count) obj/ directories to remove..." -ForegroundColor Yellow
# Remove bin directories
foreach ($dir in $binDirs) {
$fullPath = Get-ChildItem -Path . -Recurse -Directory -Filter "bin" | Where-Object { $_.Name -eq "bin" } | Select-Object -First 1 FullName
try {
Remove-Item -Path $dir -Recurse -Force -ErrorAction Stop
Write-Host "🗑️ Removed: $dir" -ForegroundColor Red
}
catch {
Write-Host "⚠️ Failed to remove: $dir - $_" -ForegroundColor Yellow
}
}
# Remove obj directories
foreach ($dir in $objDirs) {
try {
Remove-Item -Path $dir -Recurse -Force -ErrorAction Stop
Write-Host "🗑️ Removed: $dir" -ForegroundColor Red
}
catch {
Write-Host "⚠️ Failed to remove: $dir - $_" -ForegroundColor Yellow
}
}
Write-Host "🎉 Clean completed!" -ForegroundColor Green