Traversing and Creating Directories in Windows Command Prompt (cmd)
The Windows file system is organized in a tree-like structure. At the base, or root, of the tree are drives. Drives are typically given a letter to designate them. Conventionally drive letters A: and B: are used for floppy disk drives, C: is used for the local hard disk drive, D: is used for the local CD or DVD drive, and higher letters are used for network or removable drives.
Under each drive you can have a series of directories (AKA Folders), subdirectories (a directory inside of another directory), and files.
In the Windows command prompt (cmd), the directory you are currently in is known as your current working directory.
Displaying your current working directory
From the Windows Command Prompt use the cd command to display your current working directory:
> cd c:\Users\Wizard
In Windows, your current working directory is also typically displayed as part of the prompt.
Changing directories in Windows cmd
The cd command is also used to change directories, just type cd followed by the directory path you want to make your current working directory. In the following example we change from the c:\Users directory to the c:\Users\Wizard directory:
c:\Users>cd Wizard c:\Users\Wizard>
If you want to change to a directory that has spaces in the name you should put double quotes around the directory name, if you don't, you will receive an error in some versions of Windows. Here we change to the Book of Spells directory, note the use of double quotes around the name:
c:\Users\Wizard>cd "Book of Spells" c:\Users\Wizard\Book of Spells>
commands, directories, and file names in Windows are case-insensitive, meaning it does not matter if you type them using uppercase or lowercase letters.
If you need to change directories to a root drive (i.e. C: drive, D: drive, etc) be sure to include a backslash after the drive letter:
c:\Users\Wizard>cd c:\ c:\>
If you do not include the backslash after the drive letter the cd command will just display your current working directory and will not actually change to the new directory:
c:\Users\Wizard>cd c: c:\Users\Wizard c:\Users\Wizard>
As a shortcut, you can use cd and double-periods to traverse to the parent directory of your current working directory. For example, suppose you are in the c:\Users\Wizard\Book of Spells directory. If you want to change to the c:\Users\Wizard parent directory you could do this:
c:\Users\Wizard\Book of Spells>cd c:\Users\Wizard c:\Users\Wizard>
Or you can use cd .. to achieve the same result:
c:\Users\Wizard\Book of Spells>cd .. c:\Users\Wizard>
If you need to move up two or more parent directories simply add additional double-periods separated by a backslash. For example, to move up two directories from Book of Spells to Users:
c:\Users\Wizard\Book of Spells>cd ..\.. c:\Users>
Creating a directory
You can use the mkdir command followed by a name to create a directory. For example, to create a new directory inside of the current working directory called one-liners:
c:\Users\Wizard\Book of Spells>mkdir one-liners
Once created, you can cd to the directory as you normally would:
c:\Users\Wizard\Book of Spells>cd one-liners c:\Users\Wizard\Book of Spells\one-liners>