This article is from our Febooti archive, it was relevant then, and I think that it is still relevant today (a few details changed).
Another very common command is cd – Change Directory (also works in Linux). This changes the directory you are currently in.
C:\>cd \users\default
This example might not work for you if you do not have drive C, and in the drive C there are no users\default folder, however the scheme is still the same. You have to type CD followed by the root, the first \, followed by the first directory under the root, users, followed by the next directory, default. You would keep doing this until you got to your last directory.
Another useful command is being able to create directories. Directories are given names just like files are. They can contain numbers and letters but be careful of some of the special characters like * ? / ” ‘, etc. Avoid these. Also, when you make a directory try to avoid adding an extension. Directories with extension is a little bit confusing but fully valid. To make a directory, use the MD command (Make Directory). Use the following syntax:
C:\users\default>md MyDirectory
Have you ever copied and pasted a file from one folder to another? Maybe you just copied and pasted a snippet of text or a picture to another file. Suppose you wanted to copy a file and make a duplicate of that file with a different name. In the next example, we have 1 file called SourceDocument1.doc. The contents of 2nd file will be the same as we are creating a Document2.doc using our existing SourceDocument1.doc file.
C:\>copy SourceDocument1.doc Document2.doc
All that you have to do for the copy command to work is place the original file’s name first. Press the space bar. Then put what you wish to name the new, copied, document. This is a good simple way to make a backup file. There are typically two messages that will come back – ‘1 file(s) copied’ or ‘File not found’. You can always use the DIR command to make sure you have the correct filename (see previous article with DIR command examples). You can experiment with using different drive letters and directories using the same principles we used to create and change directories. To copy a group of files you can use what is called the wildcard. Here is an example:
C:\>copy *.doc D:\
In this example the *.doc matches all the files ending in .doc in current directory, and files are copied to the drive D (flash drive in my case). Be careful with the wildcard when deleting files as it is very easy to delete more than what you want to delete.
You can press the CTRL+C (Control key and the C key), looks like ^C on most documentation, to stop the copy progress or batch file from executing. In case of batch files, you will then be asked if you wish to terminate the batch file. Press a Y for yes or a N (stands for no) to continue on processing the batch script or let the current process to finish. You can also use the CTRL+Break key combination. This combination produces the same output as the CTRL+C combination (except for the Ping command). Exceptions to rules are common, but you will learn then as we go with more details.
Something that you might find interesting later on when you learn about the ECHO command is that when you enter ECHO OFF at the command prompt you will in essence “lose” your prompt. You need to type ECHO ON in order to get back to where you were. Not very useful in command prompt, but very useful when you are writing a batch file (.bat).
Next article tomorrow: What is a batch script?
Previous article: MS-DOS (cmd.exe) prompt basic commands
This article is from our Febooti archive, it was relevant then, and I think that it is still relevant today (a few details changed).
Edit Sep 26, 2014: added link to the next article.