So the past couple of blogs about this computer stuff has been useful, I showed how to write your own data backup script and how to launch a plethora of programs in two clicks. Now, I need to get to the boring stuff, teaching basic command principles. I’ll try to make this kind of stuff brief, since most people don’t really need it anyway.
So let’s start with the basics of file system navigation. We’ll need to know just a few things about how to get around directories from a command prompt.
cd – Literally stands for “change directory”, this allows you to any folder or directory you type in. cd’s syntax looks like this.
.. – That’s right, just two periods .. , this indicates you’d like to go back one directory. ..’s syntax would be…
dir – Means directory, will print a somewhat readable output of all files and folders in the directory. Dir’s syntax looks like..
12/20/2007 01:12PM <DIR> Contacts
Now as you might guess, the <DIR> means that item is a directory, so you can cd into that, actual files will have the suffixes (.jpg, .gif, .exe, etc.), and will not have the <DIR> indicator in the list.
The command prompt has something called auto-completion, by typing in a few letters of a word and hitting tab, the shell will automatically complete the word if possible. For instance:
date time <dir> ridiculouslylongfoldernamethatIwouldneverwanttotypeagain
Now, hitting the tab key…
Would automatically complete the stupidly long name for you, once you get good at cd’ing and auto-completion, you can navigate faster than what you can with a mouse.
Also, don’t forget, when cd’ing, if folder names have spaces, you MUST use quotation marks.
C:\User>cd “C:\Documents\Some Folder”
C:\User>cd “Documents and Settings” <- Only if this folder is in the current directory, auto-completion will quote it for you.
Also, if you just type in cd and then put a space and start hitting tab, it will cycle through possible directory changing choices.
It’s fairly late, so I won’t go into file manipulation, that’s for next time. This was a nice short post and should be extremely simple to understand. If you’re asking, “why learn the basics?”, it’s fairly simple, it’s the basis of scripting, once you know about syntax, arguments and parameter passing, writing correct and working scripts the first time is much easier.