How to Copy Files in Command Prompt

When the graphical user interface was not developed, it was only the command line interface on which people used to work. They had to remember the commands which at times were quite long to do the basic tasks on their computers. Even if you have to invoke a simple text editor on your computer still you would need to remember the name of the executable file of that editor so that its name could be written and executed on the command prompt. Though we have highly advanced graphical operating systems these days, but still knowledge of command prompt is a must as it helps us understand how the file system hierarchy works. If our computer crashes and we are ought to start it in command prompt, we must know how to run the commands to fix it up. So it is always good to understand the working on a command prompt. I will first introduce the very basic command which you can execute in a command prompt and this is a task which we graphically do most of the times, that is, the Copy command.

We know that we can simply right click on any file, select copy, and then paste it by the same method to some other location, but here I will tell you how to do it from the command prompt. Before we start we should understand how the file paths are defined in the command prompt.

File Path

Example : “C:Folder1MyFile.Doc”

Given above is an example of file path in which the file named MyFile.Doc is saved on the C Drive under a folder named Folder1. This is how we name the files and their locations in command line. The drive letter has to have a Colon (:) and folders are separated by a backslash ().

Copy Command

Syntax: COPY<space><from locationfile name><space><to locationfile name>

COPY is the name of the command which we need to use.

From location is the location where the file resides.

To Location is the location where you wish to copy it.

For example if you have to move the file MyFile.Doc from Folder1 to Folder2 on the C Drive then you need to write the following command.

COPY C:Folder1MyFile.Doc C:Folder2MyFile.Doc

This will copy the file from one folder to another. Please note that using the full path for a file is not always necessary. This is required if you are currently not in that directory. If you already are in the C:Folder1 directory then you can simply write the command as

COPY MyFile.Doc C:Folder2MyFile.Doc.

Again please note that full path for the destination is also always not required. If you have to copy the file to same location(with a different name) then you do not need to mention the full path. In the example given below you can copy the file MyFile.Doc with the name MyFile2.Doc in the same folder.

COPY MyFile.Doc MyFile2.Doc

Leave a Reply

Your email address will not be published. Required fields are marked *