'
I thought I found a golden egg, but unfortunately it doesn't work if the last path is missing a slash.
At this point the result is faulty as DOS assumes a path must have an ending slash.
This is a problem as paths don't have to have an ending slash to be a valid path
Code: Select all
@echo off
for %%r in (
"C:\This\Works\This Works.TMP"
"C:\This\Works\"
"C:\This\Works"
"C:\This\"
"C:\"
) do for %%r in ("%%~dpr.") do echo ParentFolderName = "%%~nxr"
pause
exit
ParentFolderName = "Works"
ParentFolderName = "Works"
ParentFolderName = "This" whoops !
ParentFolderName = "This"
ParentFolderName = ""
Druk op een toets om door te gaan. . .
And even 'This Works.TMP' could be a path, there really is no way of being sure.