How to Copy Files Using CMD in Windows

October 13, 2023 / Command Line

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

  1. Open CMD (admin) using the Start button.
  2. Execute the following command to copy “myfile.txt” from the ‘C: drive’ to the ‘E: drive’.
    copy c:\myfile.txt e:
  3. To copy all the text files in the present directory to the ‘E: drive’ with a wildcard, run the command below:
    copy *.txt e:
  4. 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

  1. 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.
  2. Open CMD (admin) using the Start button.
  3. Enter the Xcopy command to copy folders and subfolders, with their contents, as presented below.
  4. 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
  5. 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.

Managing files on remote systems?
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.

Spread the love