Fun with Windows Command Line Directory Navigation
Note: When I was writing this, I could not get the backslash character to display, so I use [backslash] to represent it in the text.
I am not new to the Windows command line. Back in my tech support days, it was frequently faster to tell callers to
- click on the menu,
- click on start,
- type “cmd,”
- click “Run,”
- type in a command (frequently it was ipconfig /all) and
- tell me what they saw
rather than walk them through opening a bunch of windows one after another.
I was reading up on tricks for navigating the Linux command line and I wondered whether they would work in Windows, so I fired up my XP box for some testing (it’s the only Windows machine I have).
I already knew about using wildcards in directory strings. This picture shows using wildcards to navigate from C:[backslash] to my My Documents directory. At the beginning, you see the full string of for the cd command. Then I return to C:[backslash] and show the same command using wild cards. (The * means “match all remaining characters”; the ? means “match any character is this location in the string.”)
What I wanted to explore was the dots. Any one who has done a dir from the command line is familiar with them:
The first, single dot or period means this directory.
The double dot or periods means the parent directory (the next one up the tree).
I verified that they can be used to navigate directories with the cd (change directory) command. This picture shows me moving from my My Documents directory to the C:[backslash] directory using the command cd .. to move up one directory at a time.
You can open a program from the command line. I opened Notepad simply by typing “notepad” and pressing enter. In this picture, the command prompt is in my My Documents directory. I used the single period meaning “this directory” to open a text file directly in my My Documents from the command line using the command notepad[space].[backslash]geekazine_test.txt (click for a larger image):
And in this picture, still in My Documents, I use the two dots (meaning parent directory) to list the contents still another directory within the parent directory (C:[backslash]Documents and Settings[backslash]frankbell[backslash].dia).
(The directory in question is the settings directory for Dia, a free and open-source diagramming program often characterized as a lighter-weight Visio. Because Dia was developed for Linux, then ported to Windows, the settings folder retains the same name as it has under Linux: .dia–in Linux the period in the beginning of the file name would have made it a hidden directory).
Remember, the command line is always faster, as long as you already know the commands.