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

How can I determine the current directory in a batch file. Other than %~dp0.

So that when I run the batch file from source folder (consisting of my files) it returns the path of source folder, where ever it may be.

share|improve this question

1 Answer 1

The environment variable %cd% contains the current folder:

H:\Downloads>type currentdir.bat
echo %cd%

H:\Downloads>echo H:\Downloads

share|improve this answer
Bear in mind that batch processing may require double-%, so %%cd%%. –  user3463 Aug 8 '12 at 6:18
@RandolphWest, not for this case –  SeanC Aug 8 '12 at 18:29
That's good to know. –  user3463 Aug 8 '12 at 20:22

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.