CSC 240 Personal Computing for Programmers


DOS Command Exercises

Setup

Notes: 

  1. Open a MS-DOS window - (a) START | PROGRAMS | MS-DOS   or    (b) START | RUN, enter in command.com and press OK.
  2. Change drive to the C: drive - just type C: and hit enter.
  3. Create a new directory called 240temp - MD 240TEMP (or MKDIR 240TEMP) and hit enter.  This is where you will do ALL your work for these exercises.
  4. Change directory to that new directory - CD 240TEMP.
  5. Create a file - COPY CON FILE1.TXT.  Now just hit a few random keystrokes to put anything in the file.  When finished, hit F6 and then enter.   You will now see the message "1 file(s) copied" which means you just created a file called file1.txt in the 240temp directory.
  6. As a check, do the following - TYPE FILE1.TXT and you will see the contents of that file (garbage).  Also do a DIR and you will see the contents of the directory you're in (c:\240temp).  You will see that file.

Exercise

Now you're ready to begin the exercises.  Each numbered item has an answer in the answer key.  Do the exercises first, on the computer and while down the answers.  Then consult the answer key.

  1. Copy FILE1.TXT and make a file2.txt, file3.dat, file4.xyz, file5.txt.  Pay attention to the names and extensions of the files.
  2. List out the directory and see ALL the newly created files.
  3. Now you just want to see a list of the files that have TXT as their extension.
  4. Make a copy of file4.xyz and call it first.dat
  5. Create a subdirectory under the directory you're currently in.  Call this new directory TESTDIR
  6. Copy all the files with an extension of DAT to the new subdirectory.
  7. Change directories to the newly created directory and list all the files in there.
  8. Delete file3.dat.
  9. Go back up to the parent directory of the current directory you are in.
  10. List all the file with an extension of DAT in the current directory and the one you just created.  Use only one command to do so.
  11. Change the name of file1.txt to file6.txt.
  12. Delete the directory you created (TESTDIR).  Are you able to do this ?  Why or Why not ?
  13. Change directories to the TESTDIR directory.  Delete the remaining file.   Change directories up to the parent directory (up one level) and now delete the directory.
  14. List all the files that start with FI and have an extension of TXT.
  15. List all the files that start with the word FILE, then a single digit an extension of TXT.

That's it...if you can get through all of this, you know enough to pass any DOS command-related questions on my tests :)