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
Based on the follow up question (store the data in a variable) in the comments to the chdir post I'm betting he wants to store the current path to restore it after changeing directories.
The original user should look at "pushd", which changes directory and pushes the current one onto a stack that can be restored with a "popd". On any modern Windows cmd shell that is the way to go when making batch files.
If you really need to grab the current path then modern cmd shells also have a %CD% variable that you can easily stuff away in another variable for reference.
For Windows we can use
cd
and for Linux
pwd
command is there.
As one of the possible codes
echo off
for /f "usebackq tokens=* delims= " %%x in (`chdir`) do set var=%var% %%x
echo The current directory is: "%var:~1%"
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).
@echo off
for /f "usebackq tokens=*" %%x in (`chdir`) do set var=%%x
echo The currenct directory is: %var%
But, of course, gmaran23's answer is the much easier one.
On Windows, type cd
for the working current path.
On Linux, pwd
for the current working path.