Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .