Goal: Delete empty folders at end of a mutli-step clean-up. rd without "Force" removes directories that are not empty.
This works:
for /f "usebackq" %%d in (`"dir O:\Folder~1\Folder /ad/b/s | sort /R"`) do rd "%%d"
These don't work:
for /f "usebackq" %%d in (`"dir \"O:\Folder With Spaces\Folder\" /ad/b/s | sort /R"`) do rd "%%d"
for /f "usebackq" %%d in (`"dir ""O:\Folder With Spaces\Folder"" /ad/b/s | sort /R"`) do rd "%%d"
for /f "usebackq" %%d in (`"dir ^"O:\Folder With Spaces\Folder^" /ad/b/s | sort /R"`) do rd "%%d"
I know I'm missing something simple...
EDIT
Adding the example below to the mix:
If I actually echo the %d it echos.... "O:\Patient". Not the full name.