Computer Science 235 :: Data Structures and Algorithms

CS 235 DOS Howto


This information is to help you get around on the lab computers. They are running Windows 2000, but most of this information should apply to any version of Windows. Also, this is by no means an exhaustive source of information. There are a lot of things that you can do in a command prompt that aren't listed here.

The quick How-To

How to open a command prompt:

Click on the Start button, go to Programs, then Accesories and finally Command Prompt.

How to change directories:

cd directoryName

How to move up a directory:

cd..

How to make a directory:

md directoryName

How to get rid of a directory:

(The directory you're trying to get rid of has to be EMPTY before you can do this.)

rmdir directoryName

How to find out what's in a directory:

dir

How to copy files: copy source destination

How to delete files:

del filename

How to change to a different drive:

driveLetter:

You read the quick How-To and have no clue

Okay, you read the the quick How-To and have no idea what it was talking about, right? Well, this part is for you. This part also has more information just in case you're one of those kinds of people who find this sort of stuff interesting.

Directories?

If you're familiar with Windows but not with DOS, a directory is the same thing as a folder. It's just a place to put a group of files or directories. That way you can group your files in some logical order. If you had to put all your files in the same place, things would get very messy very quickly. You also wouldn't be able to have two files with the same name. The first thing I would recommend doing is making a directory named cs235 or something like that on your F drive where you will keep all your 235 assignments. Then inside that directory you can make another directory for each project. That way you won't confuse files from one project with files from another project. (You also won't have the tendency to overwrite your old project files. That's a bad idea! Save everything!)

One problem that you may run into is that Windows allows you to put spaces in a directory name quite easily, but DOS doesn't care for it so much. For example, say you want to make a directory called My Stuff. So you type md My Stuff then do a dir to check out your new directory. But wait! What happened? You now have a directory called My and a directory called Stuff. Not at all what you wanted. The problem is that DOS uses a space to separate arugments to a command. All you have to do to get around this is put the name of the directory you want to create in quotes. Simply type md "My Stuff" and DOS will know that you really want that space to be a space. When you change to that directory you do the same thing. Type cd "My Stuff" to get into your new directory.

The different drives on the computer are kind of like directories, but you access them in a little different way. For example, if you bring something in on a disk and want to be able to access it you would type a: which would change you from the F drive to the A drive. Then you can type f: to get back to the F drive. Just as a side note, if you're in some directory on the F drive, then switch to the A drive and then back to the F drive it will remember what directory you were in on the F drive. Isn't that convenient?

The fine art of the dir command

Sometimes just typing dir gives you exactly what you want. But eventually you're going to run into a situation where you don't want to see every file in a directory in on big long list. What if there are more files in that directory than will fit on one screen? (Try going to C:\WINDOWS and typing dir and you'll see what I mean.) We'll go over a couple of the different things you can do with dir here. If you want to find out everything you can do type help dir

The /w option stands for wide. Instead of putting everything in one big long list it will put the files in columns. F:\> dir /w

This is a handy option that you can use to view hidden files. Just be careful as hidden files are usually hidden for a reason. F:\> dir /a

This one is great. It will display the directory one page at a time. It will pause and let you push a button before continuing. Now you can go through and see everything in the Windows directory. Just what you've been dying to do, I know! F:\> dir /p

Another useful feature of dir is the ability to use wildcards. Wildcards are use in listing some of the files in a directory but not all of them. For example: dir *.java will give you a list of all the files that end in .java. You can put the * other places as well, depending on how specific you want to get. Some more examples: dir proj*.java This will give you all the files that start with proj and end with .java. For example, proj1.java, projSuperProj.java and projection.java would all print out if they're in the directory.

The ? wildcard is a little different than the * wildcard. The * replaces any number of characters while the ? replaces only one character. Consider the following example: dir project?.java The files project1.java, project9.java and projectb.java would print out, but project12.java and projectBigProject.java would not.


Updated October 10, 2003