I have a bunch of folder many layers deep many of which have a leading space in the name - ask a mac user why they would do this cos I don't know.
Anyway I need to get rid of the leading spaces so I tried this
{
If($folder.name.length -ne $folder.name.Trim().length)
{
Rename-Item -Path $folder.name $folder.name.Trim()
}
But this doesn't work.
It recognizes that the length of the folder names are different so can distinguish between "Archive" and " Archive" but will not change and the error give n is that " Archive" does not exist.
I'm new to Powershell so I think I'm in over my head.
Please help