Try this Powershell script.
$folder = '\\?\c:\temp' # Note, requires Powershell.exe, it will not work in Powershell_ise.
Get-ChildItem -path $folder -Recurse -Directory | foreach {
if ($_.Name.EndsWith(' ')) {
$_.FullName
$_ | Rename-Item -NewName $_.Name.Trim() -whatif # remove whatif to actually do the rename.
}
}
Run it once to find a spaced folder. Then point $folder to that folder and remove the -whatif. Test the rename on the one folder before updating the entire folder structure.