Copying files in Windows with the Command Prompt (CMD) is fast and efficient. Whether you want to copy a single file, multiple files, or entire folders with subfolders, CMD offers built-in commands like ‘copy’ and ‘xcopy’.
This guide will provide you with the exact steps, accompanied by examples.
Follow the guide:
Method 1: Using the ‘Copy’ command
- Open CMD (admin) using the Start button.
- Execute the following command to copy “myfile.txt” from the ‘C: drive’ to the ‘E: drive’.
copy c:\myfile.txt e:
- To copy all the text files in the present directory to the ‘E: drive’ with a wildcard, run the command below:
copy *.txt e:
- The provided command copies the “example.xls” file from the ‘D: drive’ to the current directory. If no destination is specified, the command utilises the current directory by default.
copy d:\example.xls
Method 2: Using the ‘Xcopy’ Command
- Xcopy is a utility that facilitates the copying of individual files or groups of files between directories, offering a convenient way to duplicate data to and from a fixed drive.
- Open CMD (admin) using the Start button.
- Enter the Xcopy command to copy folders and subfolders, with their contents, as presented below.
- If you wish to copy the “example” folder and its subfolders from the ‘C drive’ to the D drive, execute the command given below:
Xcopy C:\example D:\example /E /H /C /I
- Explanation of switches-
/E– Copies all subdirectories, containing any that are empty.
/H– Includes files that are hidden or have system file attributes.
/C– Continues copying even if errors occur.
/I– Assume the destination is a directory if not sure.
In such a manner, you can copy files using “Copy” and “Xcopy” commands in the command prompt. For additional assistance, contact our support specialists.
Simplify file transfers and automation with a Windows VPS with remote access.
Interested in managing MySQL databases? Explore our guide on How to Copy a MySQL Table with phpMyAdmin.