
How to display the full path of the current directory in Windows command prompt ? Simply use the cd command and the current path is displayed in the prompt.
How to display the full path of the current directory in cmd ?
When using batch files it becomes much useful to reuse the current location path. Especially when scripting dynamic actions using variables.
Directly from the command prompt cmd.exe :
cd
From a batch script, i.e. a .bat file:
%cd%
For example, use this simple example to assign a batch variable with the current directory path and display it to the screen.
Note: to use this example, simply copy and paste the code below to a BATCH file, for example DisplayDirectory.bat and execute it.
echo off rem the previous command is disabling echo to avoid all lines on the execution screen rem setting the variable with the current directory value set VarPath=%CD% rem displaying the variable on the prompt screen echo "The current folder is:" echo %VarPath% rem setting a 15 seconds timeout to let the prompt displayed timeout 15
To go further and check out more possibilities of the cd command, this article explains how to change the current directory in MS-DOS.