How to copy files

Below are the steps required to copy computer files from one source to another. Click on one of the links below to scroll down automatically to the operating system you need help with, or scroll down to review them all.

Note: When copying files you are going to get more than one copy of the file on your computer. If you want only one copy of the files you should move the files and not copy them.

Microsoft Windows
MS-DOS and Windows command line
Linux and Unix

How to copy a file in Microsoft Windows

Copying files in WindowsBelow are the simple steps on how to copy a file or multiple files in Microsoft Windows from one location to another.

  1. Go to the files or folders you want to copy. If you need help locating the files use the Windows find feature.
  2. Highlight the file or files you want to copy. If you need to highlight more than one file, you can hold down the CTRL or Shift keys on your keyboard or drag a box around the files you want to copy.
  3. Once highlighted, right-click one of the highlighted files and select copy. Users may also press the CTRL + C shortcut key, or in Windows Explorer, click Edit at the top of the window and choose Copy.
  4. Move to the drive, folder, or other location you want to copy the files to and either right-click in the folder and choose paste or click Edit from the File Menu and then click Paste.

You can also use the Windows command line to copy files. In some situations, such as copying multiple files of a certain extension or with a certain name, it can be a lot easier.

How to copy a file in MS-DOS and the Windows command line

copy commandBelow are steps on how to copy a single file from one directory to another directory as well as how to copy multiple files from one directory to another directory.

Copying a single file

  1. Using the cd command, move to the directory that contains the file you want to copy.
  2. Type a command similar to the below command.

copy myfile.txt c:\my\location

In the above example, you would substitute "myfile.txt" with the name of the file you want to copy, and "c:\my\location" with the destination directory.

Copying multiple files to another location

  1. Using the cd command, move to the directory that contains the files you want to copy.
  2. Once in the directory that contains the files you want to copy, type a command similar to one of the below commands.

copy *.* c:\mydir

In the above example, the command would copy every file in the current directory to the "mydir" directory.

copy *.txt c:\mydir

In the above example, the command would copy every txt, or text file, in the current directory into the "mydir" directory.

Tip: Additional examples of wildcard characters can be found on our wildcard definition.

xcopy hope example /e

If you need to copy files, directories, and subdirectories use the xcopy command. In the above example this xcopy command copies all directories (even empty directories) and files from the hope directory into the example directory.

Copying files with spaces in the file names

Many times you will encounter a file with spaces in the file name. To copy these files surround the full file name and file extension in quotes as shown below.

copy "computer hope.txt" "there is hope.txt"

In the above example the "computer hope.txt" file is surrounded in quotes to let the command line know the complete file. In our example we are also copying the file to a file name with spaces so it is also surrounded in quotes.

How to copy files to another drive

You can also copy files from the current location to any other drive. For example, if you have a USB flash drive that is drive letter F: you can use the command below to copy the file all JPEG image files to the flash drive.

copy *.jpg f:

Related pages and help

How to copy files in Linux and Unix

cp commandBelow are steps on how to copy a single file from one directory to another directory as well as how to copy multiple files from one directory to another directory.

Copying a single file from one location to another.

  1. Using the cd command, move to the directory that contains the file you want to copy.
  2. Type a command similar to the below command.

cp myfile.txt /usr/bin

In the above example, you would substitute "myfile.txt" with the name of the file you want to copy, and "/usr/bin" with the destination directory.

Copying multiple files to another location

  1. Using the cd command, move to the directory that contains the files you want to copy.
  2. Once in the directory that contains the files you want to copy, type a command similar to one of the below commands.

cp *.* /usr/bin

In the above example, the command would copy every file in the current directory to the "/usr/bin" directory.

cp *.txt /usr/bin

In the above example, the command would copy every txt, or text file, in the current directory into the "/usr/bin" directory.

Additional examples of wildcard characters can be found on our wildcard definition.

Copying files with spaces in the file names

Many times you will encounter a file with spaces in the file name. To copy these files surround the full file name and file extension in quotes as shown below.

cp "computer hope.txt" "there is hope.txt"

In the above example the "computer hope.txt" file is surrounded in quotes to let the command line know the complete file. In our example we are also copying the file to a file name with spaces so it is also surrounded in quotes.

Related pages and help