In this article, I will show you how to copy files using Command Prompt in Windows 11. This method is useful if you back up your files regularly from the same source to the same target location. In such a case, you can create batch files and run them whenever you want to create a backup.
How to copy files using Command Prompt in Windows 11
Here we will show you the following two methods to copy files using the Command Prompt in Windows 11/10.
- By using the copy command
- By using the xcopy command
Let’s start.
1] The copy command
Open the Command Prompt as an administrator. Now, use the copy command. Follow the syntax written below to use the copy command:
copy <file path> <file name> <file extension> <complete path of the destination>
Suppose I want to copy a file with the name My Document with the extension .docx from the location “E:\New folder” to the location “D:\The Windows Club\New folder,” then the complete copy command will be:
copy "E:\New folder\My Document.docx" "D:\The Windows Club\New folder"
If you want to copy all the files from one location to another location, use the following syntax with the copy command:
copy <source address> <destination address>
Suppose, I want to copy all the files stored at the location “E:\” to the location “D:\The Windows Club\New folder,” then the command will be:
copy "E:\" "D:\The Windows Club\New folder"
The above command will copy all the files to the destination excluding the folders and subfolders. This is one of the limitations of the copy command.
The copy command also has some parameters that you can use along with it. The complete list of all the parameters of the copy command is available on the official website of Microsoft. I have shown the usage of some of these parameters below.
If the copy command finds a file with the same name at the destination, it will show you a message whether you want to replace it or not (refer to the above image). Suppose, you do not want the copy command to show this message, you can use the /y parameter. An example of this parameter is given below:
copy "E:\" "D:\The Windows Club\New folder" /y
The copy command has some limitations, such as it does not copy files inside the subfolders, it ignores hidden files, etc. It also has a limited number of parameters. For example, if I want to include subfolders, there is no such parameter for that. Moreover, there is no such parameter to copy the hidden files.
Read: Useful Commands to Manage Files and Folders through CMD
2] The xcopy command
The xcopy command eliminates the limitations of the copy command. It supports more parameters than the copy command. Therefore, it can do the things that the copy command cannot do, such as copying the folders and subfolders, copying the empty folders, copying the hidden files, etc.
The syntax to use the xcopy command is as follows:
xcopy <file path> <file name> <file extension> <complete path of the destination>
If you want to copy all the files from one location to another location, use the following syntax:
xcopy <source address> <destination address>
The complete list of parameters of the xcopy command is mentioned on the Microsoft’s official website. Below, I have shown some examples of using the xcopy command with some parameters.
By default, the xcopy ignores all the folders inside a particular directory. But if you want to copy the folders too, you can use the /s parameter. For example, if I want to copy the content (including folders) from the E directory to the location “D:\The Windows Club\New folder,” the command will be:
xcopy "E:\" "D:\The Windows Club\New folder" /s
The above command will copy all the content including folders, but ignore the empty folders.
If you want to copy all the files, folders, subfolders, and empty folders, use the /e parameter. Hence, in my case, the command will be:
xcopy "E:\" "D:\The Windows Club\New folder" /e
If you want to copy the files with hidden attributes (hidden files), use the /h parameter. Hence, in my case, the command will become:
xcopy "E:\" "D:\The Windows Club\New folder" /h
The parameter to suppress the prompt to overwrite the files is the same as the copy command, i.e., the /y parameter.
This is all about copying files using Command Prompt in Windows 11/10.
Read: How to Copy files from Windows to Linux using PowerShell
How do I copy text in Windows 11 CMD?
You can copy the text in Windows 11 CMD by using the same shortcut key you use to paste the copied files, i.e., Ctrl + V. Open the Command Prompt window and press the Ctrl + V keys to paste the copied text there. Alternatively, you can also use the right-click of your mouse. In the Command Prompt window, the right-click of the mouse works the same as the Ctrl + V. The same can also be used to copy the selected text in the CMD.
Read: How to open a File or Folder using Command Prompt or PowerShell
How do I copy all files in Windows 11?
You can copy all the files in Windows 11 by selecting all of them. Use the Ctrl + A shortcut to select all the files in a particular directory. Now, go to the destination location and press the Ctrl + V keys. If you want to copy some specific files, select them by pressing and holding the Ctrl key.
Read next: Robocopy in Windows.