Skip to content

Instantly share code, notes, and snippets.

@LaineZ
Created October 22, 2023 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LaineZ/e708feb9235faa8fe8a635ef42075318 to your computer and use it in GitHub Desktop.
Save LaineZ/e708feb9235faa8fe8a635ef42075318 to your computer and use it in GitHub Desktop.
PowerShell: Clean Cargo Projects recursivly
# Change your desired path
$projectFolders = Get-ChildItem -Directory -Path "D:\projects"
foreach ($folder in $projectFolders) {
$projectPath = Join-Path $folder.FullName "Cargo.toml"
if (Test-Path $projectPath) {
Write-Host "Cleaning project in $($folder.FullName)..."
Set-Location -Path $folder.FullName
Invoke-Expression -Command "cargo clean"
Set-Location -Path $PSScriptRoot
} else {
Write-Host "No Cargo.toml found in $($folder.FullName)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment