Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows shell command to get the full path to the current directory?

Is there a Windows command line command that I can use to get the full path to the current working directory?

Also, how can I store this path inside a variable used in a batch file?

like image 696
user62958 Avatar asked Mar 03 '09 19:03

user62958


People also ask

How do you display the full path of your current directory?

Use the pwd command to write to standard output the full path name of your current directory (from the /(root) directory). All directories are separated by a slash (/). The /(root) directory is represented by the first slash (/), and the last directory named is your current directory.

Which command prints the full path to the current active directory?

The answer is the pwd command, which stands for print working directory. The word print in print working directory means “print to the screen,” not “send to printer.” The pwd command displays the full, absolute path of the current, or working, directory.

How do I find the path in cmd?

Go to the destination folder and click on the path (highlights in blue). type cmd. Command prompt opens with the path set to your current folder.

What is the full path to your home directory?

So if you are in your home directory the full path is s.th. like /home/sosytee/my_script . For your home directory there is the "short-cut" ~ , meaning you can also write ~/my_script . But that will of course resolve to a different path for every user.


2 Answers

Use cd with no arguments if you're using the shell directly, or %cd% if you want to use it in a batch file (it behaves like an environment variable).

like image 116
Trevor Bramble Avatar answered Oct 02 '22 05:10

Trevor Bramble


You can set a batch/environment variable as follows:

SET var=%cd% ECHO %var% 

sample screenshot from a Windows 7 x64 cmd.exe.

enter image description here

Update: if you do a SET var = %cd% instead of SET var=%cd% , below is what happens. Thanks to jeb.

enter image description here

Capturing the current directory from a batch file

like image 30
gmaran23 Avatar answered Oct 02 '22 05:10

gmaran23