How to Copy Files with Command Line Interface

October 13, 2023 / How-to Guide

This article explains how to copy files with command line interface. You can use the “Copy” and “Xcopy” commands to copy files on your computer competently.

Let us follow the steps:

  1. Using “Copy” command- To transfer particular files.
    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 below command-
      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
  2. Using the “Xcopy” Command- To copy all files.
    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. Let us understand in detail-
      1. /E- Duplicates all subdirectories, containing any that are empty.
      2. /H- Duplicates files that are hidden or have system file attributes.
      3. /C- Regardless of encountering an error, continue the copying process.
      4. /I- Assume the destination is a directory if uncertain.

In such a manner, you can copy files using “Copy” and “Xcopy” commands in command prompt. For extra assistance, get help from our support specialists.

Spread the love