To copy a file, use the
COPY command. The command takes two names: the file name to copy, and the new file name.
- Change your working directory to a place with a small file to copy. Use
dirto see if there are any files to copy.
copy filename NewFileName, where
filenameis your actual file name to copy, and
NewFileNamecan be anything you want.
dirto 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".
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
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
.exeso Windows knows it’s a program to run
.bmpare images and will open in your default picture program
- Microsoft Word documents are usually
.txtis a plain text file that can be read by notepad or many other programs
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.
del *.pdfwill delete all pdf files in the current directory
del *.pngwill 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
To remove a directory, use
All the same naming rules you learned above apply to
RD too. You may use wildcard characters to specify multiple directory names at once.
To exit Command Prompt without your mouse, use the
EXIT command. Pretty simple right?
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 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.