Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to do so by using findstr on %cd% but couldn't find a way to do so without using a file to process. And the g:/ option seems to mean findstr runs interactively and cannot be piped into. So without using files is there a way?

share|improve this question
You’ll have to explain a little more; it is not quite clear what you are trying to do or what the problem. – Synetech Mar 13 '11 at 19:43

Assuming that you want to set a variable to contain the name of the parent of the current directory (in a .cmd file):

for %%i in (.) do set parent=%%~dpi
echo parent %parent%

See help for for more information on the tilde substitutions.

If you just want to set a variable to the current directory:

set dir=%cd%
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.