param(
    [Parameter(Mandatory = $true)]
    [string] $Root
)
if (-not (Test-Path -LiteralPath $Root)) { exit 0 }
$dirs = @(Get-ChildItem -LiteralPath $Root -Recurse -Directory -Filter 'eaDir_tmp' -ErrorAction SilentlyContinue |
    Sort-Object { $_.FullName.Length } -Descending)
foreach ($d in $dirs) {
    try {
        Remove-Item -LiteralPath $d.FullName -Recurse -Force
        Write-Host "Removed: $($d.FullName)"
    } catch {
        Write-Host "Failed: $($d.FullName)"
    }
}
