How do I find the local path on Windows in a command prompt?
-
23Very useful information, although I believe this now belongs in superuser.com – Ramon Zarazua B. Feb 02 '10 at 21:10
12 Answers
This prints it in the console:
echo %cd%
or paste this command in CMD, then you'll have pwd
:
(echo @echo off
echo echo ^%cd^%) > C:\WINDOWS\pwd.bat

- 71,951
- 46
- 188
- 305

- 6,358
- 1
- 16
- 8
-
6i got access denied and searched for solution , it took time so switched to another answer `cd` only – shareef Jul 07 '15 at 20:18
-
1This does not print the full directory name if you have accessed the directory via the ~ notation, e.g. "C:\PROGRA~3" – voutasaurus Jan 10 '16 at 04:52
-
25Why do you need to `echo`? Just `cd` by itself seems to work fine. – Kevin Workman Feb 07 '18 at 05:20
-
2`cd /?` says `Type CD without parameters to display the current drive and directory.` – phuclv May 01 '19 at 03:01
-
@shareef well when you wanna write into C:\windows you might need admin. but you could just write it somewhere you have permissions and add it to your path. the point of this second block is to basically have a pwd alias for convenience – My1 Oct 16 '20 at 22:07
-
2if using as an argument to say `docker`, you can use ${PWD} if in windows powershell. `%cd` is fine if using Cmd prompt. – jimh Jan 12 '21 at 07:48
-
`echo %cd%` doesn't work when chaining commands, e.g. `cd C:\ && echo %cd%` -> wrong output. – serg06 Mar 16 '21 at 00:51
-
This doesn't work with `doskey` though. If you do `doskey pwd=echo %cd%` you'll permanently have it set to the working directory _when the `doskey` was run_. The correct approach is `doskey pwd=cd`. – ADTC Sep 12 '21 at 09:33
-
1It doesn't work in PowerShell, so not very robust for all window users – Eric Burel Feb 21 '22 at 11:07
-
It is cd
for "current directory".

- 187,200
- 47
- 362
- 445
-
10If you need it in a variable or so, using the %CD% pseudo-variable is probably easier. – Joey May 28 '09 at 16:32
-
30
-
12Related side note: While on Windows `cd` alone will print the current working directory, on Linux it will change to your user's home directory without printing anything. So beware if you're looking for something cross platform. – Daniel Stevens Aug 31 '18 at 09:29
-
2@DanielStevens the help line from `cd` says *Displays the name of or changes the current directory.* – phuclv May 01 '19 at 03:00
-
1@phuclv correct, the *Windows* documentation for [cd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cd) does say that. The *Linux* documentation for [cd](http://linuxcommand.org/lc3_man_pages/cdh.html) says that when no path is given, it will change to your home directory. My local man pages use the wording: *"Change the current directory to dir. if dir is not supplied, the value of the HOME shell variable is the default."* – Daniel Stevens May 02 '19 at 10:09
Open notepad as administrator and write:
@echo %cd%
Save it in c:\windows\system32\ with the name "pwd.cmd" (be careful not to save pwd.cmd.txt)
Then you have the pwd command.

- 1,022
- 1
- 12
- 23

- 335
- 3
- 2
cd ,
it will give the current directory
D:\Folder\subFolder>cd ,
D:\Folder\subFolder

- 37,963
- 15
- 156
- 475

- 311
- 3
- 3
-
11
-
3in cmd [`,`, `;`, `=` are also delimiters just like space and tab](https://ss64.com/nt/syntax-esc.html), therefore `cd ,` is no different from `cd =;=` or `cd
` – phuclv May 11 '19 at 02:37 -
-
@EricBurel it works in cmd. It has nothing to do with Windows 10 because it's a shell feature, and if you use a different shell like powershell then obviously it won't work. Each shell has different syntax and powershell is the default in many new installations – phuclv Jul 21 '23 at 01:54
cd
without any parameters is equivalent to pwd
on Unix/Linux.
From the console output of typing cd /?
:
Displays the name of or changes the current directory.
[...]
Type CD without parameters to display the current drive and directory.

- 10,044
- 4
- 41
- 58
You can just type
cd
it will return you the current path.
-
this is exactly like Daniel A. White's answer above. Why on earth duplicated answers on this got so many upvotes – phuclv Jul 21 '23 at 01:57
In PowerShell pwd
is an alias to Get-Location
so you can simply run pwd
in it like in bash
It can also be called from cmd like this powershell -Command pwd
although cd
or echo %cd%
in cmd would work just fine

- 37,963
- 15
- 156
- 475
-
That's the right answer that works for both cmd and PowerShell. How to extract the path though? – Eric Burel Feb 21 '22 at 11:08
hmm - pwd works for me on Vista...
Final EDIT: it works for me on Vista because WinAvr installed pwd.exe and added \Program Files\WinAvr\Utils\bin to my path.

- 11,792
- 3
- 44
- 56
-
1
-
I'm not using powershell. I seem to recall something about command extensions but can't find a checkbox anywhere for that. I've also got
completion in my Command Prompt. I could swear there used to be an applet in Control Panel to enable command extensions but I can't find it now. – sean e May 28 '09 at 17:26 -
Command extensions are enabled by default on Windows NT and later. Tab completion is separate from that and was available from Windows 2000 onwards and enabled by default since XP. pwd only works here because I have a pwd.cmd with "echo %cd%" in my path. You can use gcm pwd in Powershell to check where it comes from on your machine (sort of like which(1), only better). – Joey May 28 '09 at 19:44
-
gcm pwd reports that pwd is an Alias with a definition of Get-Location. – sean e May 28 '09 at 20:08
-
2Late to the party but usually you can figure out the location where pwd is coming from by the command 'where' on command prompt. – veepsk Sep 25 '15 at 14:15
C:\Documents and Settings\Scripter>echo %cd%
C:\Documents and Settings\Scripter
C:\Documents and Settings\Scripter>
for Unix use pwd
command

- 37,963
- 15
- 156
- 475
-
don't you see `for Unix use pwd command` useless? Because it's what the OP asked – phuclv May 11 '19 at 02:34
-
1
-
@EricBurel that's so obvious. PowerShell uses different syntax and use `$` for variables like most other shells instead of `%%` like in cmd – phuclv Jul 21 '23 at 01:56
Use the below command
dir | find "Directory"

- 37,963
- 15
- 156
- 475
-
this won't work if there's a file or folder named "Directory" in the current directory, or if Windows language is not English, because output of `dir` is localized – phuclv May 01 '19 at 03:07
You can simply put "." the dot sign. I've had a cmd application that was requiring the path and I was already in the needed directory and I used the dot symbol.
Hope it helps.

- 1
- 2