cd — Change directory 3
. cd \a\b\c\d\e\f\g
C:\a\b\c\d\e\f\g
. cd ..
C:\a\b\c\d\e\f
. cd ...
C:\a\b\c\d
. cd ....
C:\a
When we typed cd d:, we changed to the current directory of the D drive. We navigated our
way to d:\kande\additional detail with three commands: cd d:, then cd kande, and then
cd "additional detail". The double quotes around “additional detail” are necessary because of
the space in the directory name. We could have changed to this directory in one command: cd
"d:\kande\additional detail".
Notice the last three cd commands in the example above. You are probably familiar with the
cd .. syntax to move up one directory from where you are. The last two cd commands above let you
move up more than one directory: cd ... is shorthand for “cd ..\..” and cd .... is shorthand
for “cd ..\..\..”. These shorthand cd commands are not limited to Stata; they will work in your
Command window under Windows as well.
You can see the current directory (where Stata saves files and looks for files) by typing pwd. You
can change the current directory by using cd or by selecting File > Change working directory....
Stata’s cd command understands “
~
” as an abbreviation for the home directory, so you can type things
like cd
~
\data.
. pwd
C:\Users\bill\proj
. cd "
~
\data\city"
C:\Users\bill\data\city
.
If you now wanted to change to "C:\Users\bill\data\city\ny", you could type cd ny. If you
wanted instead to change to "C:\Users\bill\data", you could type “cd ..”.
Stata for Mac
Read [U] 11.6 Filenaming conventions for a description of how filenames are written in a command
language before reading this entry.
Invoking an application and then changing folders is an action foreign to most Mac users. If it is
foreign to you, you can ignore cd and pwd. However, they can be useful. You can see the current
folder (where Stata saves files and looks for files) by typing pwd. You can change the current folder
by using cd or by selecting File > Change working directory.... Stata’s cd command understands
“
~
” as an abbreviation for the home directory, so you can type things like cd
~
/data.
. pwd
/Users/bill/proj
. cd "
~
/data/city"
/Users/bill/data/city
.
If you now wanted to change to "/Users/bill/data/city/ny", you could type cd ny. If you
wanted instead to change to "/Users/bill/data", you could type “cd ..”.