How to copy files
To copy computer documents, pictures, or other files from one place to another, follow these instructions.
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, move them instead. For help with moving, see: How to move files and folders on the computer.
A file name must be unique. If it's not, a number is appended to the end of a file name. It may also have "- Copy" appended to the end of the file name, instead of a number. Appending a number to the end of the copied file's name assures the copied file is unique. For example, if the original file name is abc123.pdf and a copy is created in the same directory or folder, the copied file name could be abc123(1).pdf or abc123 - Copy.pdf.
Select your operating system in the list below to view the instructions that apply to you.
How to copy a file in Microsoft Windows
Below are the steps to copy a file or multiple files in Microsoft Windows from one location to another.
- Go to the files or folders you want to copy. If you need help locating the files, use the Windows find feature.
- Highlight the file or files you want to copy by clicking them once with the mouse. If you need to highlight more than one file, hold down the Ctrl or Shift keys on your keyboard, or drag a box around the files you want to copy.
- Once highlighted, right-click one of the highlighted files and select Copy. Users may also press the Ctrl+C keyboard shortcut, or in Windows Explorer, click Edit at the top of the window and select Copy.
- Open the destination folder, right-click an empty space in the folder, and select Paste. Or, in the menu bar at the top, click File, choose Edit, then select Paste.
To copy only a certain type of file, click the Type column in Windows Explorer. This action sorts files by type, rather than by name. Once grouped by type, you can select only the files with the type you want to copy, and then copy those files.
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 easier.
How to copy a file in MS-DOS and the Windows command line
Below are steps to copy a single file from one directory to another directory in MS-DOS or the Windows command line.
Copying a single file
- Using the cd command, move to the directory containing the file you want to copy.
- Type a command similar to the following.
copy myfile.txt c:\my\location
In the example above, substitute "myfile.txt" with the name of the file you want to copy, and "c:\my\location" with the destination directory. To see files available in the current directory, use the dir command.
Copying multiple files to another location
Below are the steps to copy multiple files from one directory to another directory.
- Using the cd command, move to the directory containing the files you want to copy.
- Once in the directory containing the files you want to copy, type a command similar to one of the following commands.
copy *.* c:\mydir
In the example above, the command would copy every file in the current directory to the "mydir" directory.
copy *.txt c:\mydir
In the example above, the command would copy every txt, or text file, in the current directory to the "mydir" directory.
For additional examples of wildcard characters, see our wildcard definition.
xcopy hope example /e
If you need to copy files, directories, and subdirectories, use the xcopy command. In the example above, the xcopy command copies all directories (even empty directories) and files from the "hope" directory to the example directory.
Copying long file name files or files with spaces
Often, you can encounter a file with spaces in the file name. To copy these files, surround the full file name and file extension in quotes.
copy "computer hope.txt" "there is hope.txt"
In the example above, the "computer hope.txt" file is surrounded in quotes to let the command line know the complete file name, thus eliminating the spaces.
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 (Universal Serial Bus) flash drive that is drive letter F:, you can use the following command to copy all JPEG (Joint Photographic Experts Group) image files to the flash drive.
copy *.jpg f:
How to make a copy of a file into the same directory
copy example.txt backup.txt
In the example above, the file "example.txt" is copied to the same directory as "backup.txt," effectively making a backup copy of the file.
Related pages and help
- See the cd command, dir command, copy command, and xcopy command pages for further information about each MS-DOS command.
- How to use the Windows command line (DOS).
Batch file
To perform any copy command in a batch file, include any of the Windows command line copy commands above in a batch file.
How to copy files in Linux and Unix
Below are steps to copy a single file from one directory to another directory in Linux and Unix.
Copying a single file from one location to another
- Using the cd command, move to the directory containing the file you want to copy.
- Type a command similar to the following.
cp myfile.txt /usr/bin
In the example above, substitute "myfile.txt" with the name of the file you want to copy, and "/usr/bin" with the destination directory. To see files available in the current directory, use the ls command.
Copying multiple files to another location
Below are the steps to copy multiple files from one directory to another directory.
- Using the cd command, move to the directory containing the files you want to copy.
- Once in the directory containing the files you want to copy, type a command similar to one of the following commands.
cp *.* /usr/bin
In the example above, the command would copy every file in the current directory to the "/usr/bin" directory.
cp *.txt /usr/bin
In the example above, the command would copy every txt, or text file, in the current directory to the "/usr/bin" directory.
For additional examples of wildcard characters, see our wildcard definition.
Copying files with spaces in the file names
Often, you can encounter a file with spaces in the file name. To copy these files, surround the full file name and file extension in quotes.
cp "computer hope.txt" "there is hope.txt"
In the example above, the "computer hope.txt" file is surrounded in quotes to let the command line know the complete file name. In our example, the destination file name contains whitespace (spaces), so the name is enclosed in quotes.
How to make a copy of a file into the same directory
cp example.txt backup.txt
In the example above, the file "example.txt" is copied to the same directory as "backup.txt," effectively making a backup copy of the file.
Related pages and help
- See the cd command, cp command, and ls command pages for additional information about these commands.
- For general help using the Linux command line, see our Linux and Unix shell tutorial.
How to copy files in Apple macOS
Drag-and-drop
Highlight the files you want to copy. Then, click the highlighted files with the left mouse button and, while continuing to hold down the mouse button, drag-and-drop the files to where you want to copy them. When you release the mouse button, the files are copied.
Keyboard shortcut
You can also copy files using keyboard shortcuts by following these steps.
- Highlight the files you want to copy.
- Press the keyboard shortcut Command+C.
- Navigate to the location where you want to move the files.
- Press Command+V to paste the copied files.
Terminal
To copy files in a Terminal session, use the cp command.