Do you need to copy and paste files or folders without using the File Explorer? While navigating the file system with Windows Command Prompt (cmd) might seem daunting, it's actually pretty easy once you get the hang of it. This wikiHow will teach you how to copy one or more files from one folder to another from the command line in Windows.
Steps
-
Find out your file's location . You'll need the file's location—also known as a "directory"—in order to tell Command Prompt where to look for the file.
- You can find the file's directory by going to the file's location in File Explorer and then clicking the URL bar near the top of the File Explorer window.
- Most files will be somewhere in the following directory: [drive letter]:\Users\[username] (for example, "C:\Users\Kyle"). This is the directory in which almost every user-created file on your computer is located.
- A file on your desktop for the above example would be in the "C:\Users\Kyle\Desktop" directory, while a file in the Documents folder would be in the "C:\Users\Kyle\Documents" directory.
-
Know your file's name. If you want to copy your file , you'll need to know its name. Keep in mind that file names are case-sensitive in Command Prompt, so you'll need to include the proper capitalization.Advertisement
-
Type in command prompt . Doing so will search your computer for the Command Prompt program. [2] X Research source
-
Click Command Prompt. It's at the top of the Start window. Doing so will open the Command Prompt program. [3] X Research source
- Keep in mind that if you're on a shared computer (e.g., a school or public PC), you may not be able to access the Command Prompt.
-
Enter the "change directory" command. Type in cd followed by a space, but don't press ↵ Enter . [4] X Research source
-
Type in your file's directory. Enter the directory in which the file that you want to copy is located.
-
Press ↵ Enter . Doing so will reset Command Prompt to look in the entered directory.
-
Enter the "copy" command. Type in copy followed by a space, but don't press ↵ Enter yet. [5] X Research source
-
Enter your file's name. Type in your file's name followed by a space, making sure to include the file's extension (e.g., .txt ) for a text file. Don't press ↵ Enter after doing so. [6] X Research source
- If there are spaces in the file's name, you need to put quotation marks around them. For example, a file named "Pickles are Good.txt" would be Pickles" "are" "Good.txt in Command Prompt.
-
Enter a destination directory. Type in another directory (e.g., C:\Users\[you]\Desktop into which you want to copy the file.
- If you don't do this, the file will be copied to your user directory (e.g., "C:\Users\[you]") by default.
-
Press ↵ Enter . Doing so will copy the file into your indicated directory. You can view the copied file by going to the directory in question in your computer's File Explorer.
-
Enter the robocopy command. Type in robocopy and then a space, but don't press ↵ Enter yet. [8] X Research source
-
Enter a folder's name . Type in the name of the folder that you want to copy, then add a space. Again, don't press the ↵ Enter key just yet.
- As with file names, you'll need to use quotes around any spaces in the folder name.
-
Enter a destination. Type in a directory into which you want to copy the folder's files.
- If there are lots of files in the folder, this can get messy if you copy them into an unorganized folder since the folder itself won't be copied with the files.
-
Press ↵ Enter . Doing so will copy the contents of the folder into your destination folder.
Community Q&A
-
QuestionWhich command should I use to copy files?Community AnswerCopy "source path" "destination path". For example, you might copy "C:\Users\qclab\Desktop\Stuff.txt" "P:\IT\Confidential". The quotation marks are optional unless you have spaces in your folder or file names. To copy everything in a folder use *.* as the name and extension. For example, copy "C:\Users\qclab\Desktop\Stuff.txt" "P:\IT\Confidential".
-
QuestionIs it possible to move a PDF file from one folder to another and not have it overwrite another file with the same name by having a different date?Community AnswerYou'll have to rename the PDF file prior to moving it, as two files with the same name can't reside in the same folder.
-
QuestionHow can I copy all files from sub directories with a similar name to a different directory?Community AnswerAfter you do one, press the up key and then change the name, which shouldn't take up much time.
Tips
- If you want to create a new destination folder for a set of copied files, enter the directory for the destination folder (including the destination folder itself) in conjunction with the "robocopy" command. [9] X Research sourceThanks
- You can copy all files in a directory by typing copy *[file type] (e.g., copy *.txt ).Thanks
- If you copy the Desktop folder's contents into a new folder, that new folder will be renamed to "Desktop".Thanks
Warnings
- Copying files and folders within Command Prompt is potentially dangerous if you don't know what you're doing. Never copy or manipulate any files or folders that you don't understand.Thanks
References
- ↑ https://grok.lsu.edu/article.aspx?articleid=18026&printable=y
- ↑ https://grok.lsu.edu/article.aspx?articleid=18026&printable=y
- ↑ https://www.freecodecamp.org/news/how-to-open-the-command-prompt-in-windows-10/
- ↑ https://www.computerhope.com/issues/ch000766.htm#command-line
- ↑ https://www.computerhope.com/issues/ch000766.htm#command-line
- ↑ https://www.computerhope.com/issues/ch000766.htm#command-line
- ↑ https://www.computerhope.com/issues/ch000766.htm#command-line
- ↑ https://www.computerhope.com/robocopy.htm
- ↑ https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy#examples
About This Article
1. Type "cd" followed by a space in command prompt, but don't press "enter" yet.
2. Type the name of the directory your filed is located in.
3. Press "enter."
4. Type "copy" followed by a space, but don't press "enter."
5. Type your file's name followed by a space, but don't press "enter."
6. Type in the name of the directory you want to copy the file to.
7. Press "enter" to copy the file.