In this article, you will learn how to copy individual files and files from a folder in Windows using the command line.
Part 1 of 3: How to Prepare to Copy
Step 1. Determine where the file is located
You need to find out in which directory the file is stored in order to specify it on the command line.
- To find the directory, in Explorer, navigate to the folder with the file, and then click on the address bar at the top of the Explorer window.
- Most of the files are located in the following directory: [drive letter]: \ Users [username] (for example, "C: \ Users \ John"). This directory contains almost all files created by the user.
- For example, the file on the desktop is in the following directory: C: \ Users \ Ivan \ Desktop, and the file is in the Documents folder in the C: \ Users \ Ivan \ Documents directory.
Step 2. Make a note of the file name
This is required to copy the file. Keep in mind that the command line is case sensitive, so write down the file name correctly.
Step 3. Open the Start Menu
Click on the Windows logo in the lower left corner of the screen.
Step 4. Enter Command Prompt
This will search for the Command Line utility.
Step 5. Click "Command Prompt"
You will find this icon at the top of the Start menu. A command prompt window will open.
Be aware that on a public computer (like a school), you won't be able to open a command prompt
Part 2 of 3: How to copy a single file
Step 1. Enter the command to change directory
Enter cd and then press Space; do not press the ↵ Enter key.
Step 2. Enter the directory where the required file is located
Step 3. Press ↵ Enter
On the command line, you will change to the specified directory.
Step 4. Enter the command to copy the file
Enter copy and then press Space; do not press the ↵ Enter key.
Step 5. Enter a name for the file
Enter a file name and then press Space. Enter the file name with the file extension (eg.txt in case of a text file). Do not press the ↵ Enter key.
If there are spaces in the file name, enclose them in quotation marks. For example, the file name "Pickles are Good.txt" on the command line would be: Pickles "" are "" Good.txt
Step 6. Enter the destination directory
Enter a directory (for example, C: \ Users [your username] Desktop where the file will be copied.
If you do not enter a destination directory, the file will be copied to your personal directory (for example, "C: \ Users [your username]")
Step 7. Press ↵ Enter
The file will be copied to the specified directory. To open the copied file, navigate to the appropriate directory in the Explorer window.
Part 3 of 3: How to copy files from a folder
Step 1. Go to the directory with the folder
Type cd, press Space, enter the directory with the folder and press ↵ Enter.
For example, to copy files from the Example folder on your desktop, enter the C: \ Users \ Ivan \ Desktop directory
Step 2. Enter the robocopy command
Enter robocopy and then press Space; do not press the ↵ Enter key.
Step 3. Enter the name of the folder
Enter the name of the folder you want to copy files from, and then press Space. Do not press the ↵ Enter key.
If there are spaces in the folder name, enclose them in quotation marks
Step 4. Enter the destination directory
Enter the directory where you want to copy the files from the folder.
If there are many files in the source and destination folders, they will get mixed up because the source folder itself will not be copied
Step 5. Press ↵ Enter
The file from the source folder will be copied to the destination folder.
- To copy all the files in the directory, enter the copy * [file type] command (for example, copy *.txt).
- To create a destination folder and copy multiple files into it at once, enter the destination folder directory (including the destination folder itself) in conjunction with the "robocopy" command.
- If you copy files that are on your desktop to a new folder, it will be renamed to Desktop.