How do I get the name of the parent folder in a command prompt?

Posted by Bernhard Hofmann on Stack Overflow See other posts from Stack Overflow or by Bernhard Hofmann
Published on 2010-06-09T07:40:15Z Indexed on 2010/06/09 9:22 UTC
Read the original article Hit count: 228

I'm in a Windows Command Line and want the parent folder in a variable.

Assuming current directory is "C:\foo\bar", how can I get the value "bar"?

I'm expecting something like a "find last backslash in CD and that's it".

And please, no powershell references; I want plain old Windows Command Line operations.

© Stack Overflow or respective owner

Related posts about Windows

Related posts about command-line