More Commands

File Copy

To copy a file, use the COPY command. The command takes two names: the file name to copy, and the new file name.

  1. Change your working directory to a place with a small file to copy. Use dir to see if there are any files to copy.
  2. Type copy filename NewFileName, where filename is your actual file name to copy, and NewFileName can be anything you want.
  3. Type dir to make sure your file was copied.

As in the previous section, to specify a name that contains spaces, use quotes around the name. Example: copy "work notes.txt" "work notes 2.txt".

Filename Extensions

Since you are doing the hard work of writing a new file name, make sure to keep the filename extension in the new name too. The filename extension is the final characters after a dot in the filename. For example, menu.pdf has a filename extension of pdf.

You are allowed to ignore filename extensions, but then Windows won’t know which program to open the file with. By default, Windows hides common file extensions from most users. Since you’re using Command Prompt, you will now see all of them. Over time you will become familiar with the filename extensions used in your computer. Examples:

  • cmd.exe is a .exe so Windows knows it’s a program to run
  • .png.jpg, and .bmp are images and will open in your default picture program
  • Microsoft Word documents are usually .doc and .docx
  • .txt is a plain text file that can be read by notepad or many other programs

File Delete

To delete a file, use the DEL command. Be careful! Try deleting the file copy you just made. Type DEL filename with the file name you want deleted.

Deleted files will not go to the Recycle Bin. They are gone forever.

You can delete multiple files at once by using the wildcard character *. If you type a file name with an asterisk, Command Prompt will internally replace the asterisk with as many matches as it can.

For example:

  • del *.pdf will delete all pdf files in the current directory
  • del *.png will delete all png files in the current directory
  • del "Taxes for year 20*.zip" will delete all files matching the pattern, such as “Taxes for year 2016.zip”, “Taxes for year 2017.zip”, “Taxes for year 20.zip”, and even “Taxes for year 20sfkjjksdfjk.zip”
  • del * will delete every file in the current directory

Make and Remove Directory

To make a directory, use MD NewDirectoryName.

To remove a directory, use RD DirectoryNameToDelete.

All the same naming rules you learned above apply to MD and RD too. You may use wildcard characters to specify multiple directory names at once.

Exit

To exit Command Prompt without your mouse, use the EXIT command. Pretty simple right?

Help

Use the HELP command to see a list of more built-in Command Prompt commands. This list is not comprehensive at all. The real power of Command Prompt comes from branching out of these commands and running programs and scripts.

For any of the commands in that list, you may type their name as an argument to HELP to see detailed command info. For example, try help mdor help cd and you will see a description of what the command does.

We are going to cover how to read detailed argument in the next section.


Prev ————————– Next

Leave a Reply

Your email address will not be published.