Write-Host "Cleaning up build files in all Flutter and Android projects..." $rootPath = Get-Location Get-ChildItem -Path $rootPath -Recurse -Directory | ForEach-Object { $currentDir = $_ $flutterProject = Join-Path $currentDir.FullName "pubspec.yaml" $androidProject = Join-Path $currentDir.FullName "android\gradlew" if (Test-Path $flutterProject) { Write-Host "Cleaning Flutter project in $($currentDir.FullName)..." Set-Location $currentDir.FullName & flutter clean } if (Test-Path $androidProject) { Write-Host "Cleaning Android project in $($currentDir.FullName)..." Set-Location (Join-Path $currentDir.FullName "android") & .\gradlew clean Set-Location $rootPath } # Delete APK files, AAB files, other build files, and additional useless files Get-ChildItem -Path $currentDir.FullName -Recurse -Include *.apk, *.aab, *.a, *.log, *.tmp, *.bak, *.swp, .DS_Store | Remove-Item -Force # Delete unnecessary folders $foldersToRemove = @("build", "node_modules", "temp") $foldersToRemove | ForEach-Object { $folderPath = Join-Path -Path $currentDir.FullName -ChildPath $_ if (Test-Path $folderPath) { Remove-Item -Recurse -Force $folderPath } } } Write-Host "All done! Build files and other useless files have been cleaned up in all projects."