[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

How can I get the current .bat directory i'm in

I'm trying to figure out how to get the directory of a .bat file i'm currently in. Can someone help me out?

I wasn't finding what I needed on the web
0
Mark_Co
Asked:
Mark_Co
3 Solutions
 
Evan CutlerCommented:
Look at this article.
The user Wize Owl puts in relatively simple.

http://www.msfn.org/board/topic/56320-retrieve-current-directory-name-in-batch/
0
 
David Johnson, CD, MVPOwnerCommented:
echo %cd%
or
set current = %cd%
0
 
QlemoC++ DeveloperCommented:
Attention with the example of ve3ofa! No spaces between var names, equal sign and values, as they are part of the respective value!
   set current=%cd%

But otherwise, %cd% is the current folder, as stated, and %~dp0 is the batch file's folder. It depends on which one you want to work with.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now