How to get parent path of

2020-07-23 03:20发布

问题:

How do I get the parent path of the current %CD%.

For instance:

ECHO %CD%

result: C:\Windows\System32

(This does not work)

ECHO %CD%..\

desired result: C:\Windows

回答1:

Try changing the current directory and then using %cd%:

pushd ..
echo %cd%
popd