How do I find the local path on windows in a command prompt?
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
-
4i got access denied and searched for solution , it took time so switched to another answer
cd
only – shareef Jul 7 '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 4:52
-
16
-
1
cd /?
saysType CD without parameters to display the current drive and directory.
– phuclv May 1 '19 at 3: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
It is cd
for "current directory".
-
10If you need it in a variable or so, using the %CD% pseudo-variable is probably easier. – Joey May 28 '09 at 16:32
-
12
-
10Related 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 9:29 -
1@DanielStevens the help line from
cd
says Displays the name of or changes the current directory. – phuclv May 1 '19 at 3:00 -
@phuclv correct, the Windows documentation for cd does say that. The Linux documentation for cd 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 2 '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.
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.
cd ,
it will give the current directory
D:\Folder\subFolder>cd ,
D:\Folder\subFolder
-
6
-
1in cmd
,
,;
,=
are also delimiters just like space and tab, thereforecd ,
is no different fromcd =;=
orcd <space>
– phuclv May 11 '19 at 2:37
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.
-
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 <tab> 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
-
don't you see
for Unix use pwd command
useless? Because it's what the OP asked – phuclv May 11 '19 at 2:34
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
Use the below command
dir | find "Directory"
-
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 1 '19 at 3: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.