Difference between revisions of "Copy Files in Command Prompt"

Kipkis (Kipkis | contribs)
(importing article from wikihow)
 
Kipkis (Kipkis | contribs)
m (Update ref tag)
Line 9: Line 9:
 
#*[[Copy-Files-in-Command-Prompt#ROBOCOPY_sub|{{samp|ROBOCOPY}}]] - This is the newest copy command available in the Windows Command Prompt. It requires Windows Vista or later. Windows XP users can install the [http://www.microsoft.com/en-us/download/details.aspx?id=17657 Windows 2003 Server Resource Kit Tools pack] to use it. {{samp|robocopy}} is designed to mirror files and directories while maintaining permissions and other attributes. It also allows for better logging and more reliable copying of large amounts of data.
 
#*[[Copy-Files-in-Command-Prompt#ROBOCOPY_sub|{{samp|ROBOCOPY}}]] - This is the newest copy command available in the Windows Command Prompt. It requires Windows Vista or later. Windows XP users can install the [http://www.microsoft.com/en-us/download/details.aspx?id=17657 Windows 2003 Server Resource Kit Tools pack] to use it. {{samp|robocopy}} is designed to mirror files and directories while maintaining permissions and other attributes. It also allows for better logging and more reliable copying of large amounts of data.
 
===COPY===
 
===COPY===
<ol><li>Copy a single file. The {{samp|copy}} command is best used when copying a single file. To use the basic {{samp|copy}} command, you'd type {{kbd|copy {{var|source}} {{var|destination}}}}. For example, to copy the file {{samp|Example.txt}} from {{samp|C:\Users\desktop}} to {{samp|D:\backup}}, enter the following:<ref>http://www.xtraficient.com/batch-files/copy-and-rename-files</ref>
+
<ol><li>Copy a single file. The {{samp|copy}} command is best used when copying a single file. To use the basic {{samp|copy}} command, you'd type {{kbd|copy {{var|source}} {{var|destination}}}}. For example, to copy the file {{samp|Example.txt}} from {{samp|C:\Users\desktop}} to {{samp|D:\backup}}, enter the following:<ref name="rf18250">http://www.xtraficient.com/batch-files/copy-and-rename-files</ref>
 
{{CodeBox|
 
{{CodeBox|
 
<source lang="dos">
 
<source lang="dos">
Line 31: Line 31:
 
</source>
 
</source>
 
}}</li>
 
}}</li>
<li>Combine (concatenate) text files. One of the "hidden" functions of the {{samp|copy}} command is its ability to join multiple files together. This is most useful with plain text files. The content from the first and second text files in the following command will be combined, in order, into the new file:<ref>https://support.microsoft.com/en-us/kb/240268</ref>
+
<li>Combine (concatenate) text files. One of the "hidden" functions of the {{samp|copy}} command is its ability to join multiple files together. This is most useful with plain text files. The content from the first and second text files in the following command will be combined, in order, into the new file:<ref name="rf18251">https://support.microsoft.com/en-us/kb/240268</ref>
 
{{CodeBox|
 
{{CodeBox|
 
<source lang="dos">
 
<source lang="dos">
Line 39: Line 39:
 
<ul><li>This command assumes that {{samp|file1.txt}} and {{samp|file2.txt}} are located in the current directory. You'll need to add the path to the beginning of each file name for files in other locations.</li></ul></li></ol>
 
<ul><li>This command assumes that {{samp|file1.txt}} and {{samp|file2.txt}} are located in the current directory. You'll need to add the path to the beginning of each file name for files in other locations.</li></ul></li></ol>
 
===XCOPY===
 
===XCOPY===
<ol><li>Use [[Copy-Files-in-Command-Prompt#COPY_sub|{{samp|COPY}}]] for single files. You're better off with the {{samp|copy}} command for single files. The {{samp|xcopy}} command does not allow you indicate whether you are setting a directory or a filename as the destination.<ref>http://ss64.com/nt/xcopy.html</ref></li>
+
<ol><li>Use [[Copy-Files-in-Command-Prompt#COPY_sub|{{samp|COPY}}]] for single files. You're better off with the {{samp|copy}} command for single files. The {{samp|xcopy}} command does not allow you indicate whether you are setting a directory or a filename as the destination.<ref name="rf18252">http://ss64.com/nt/xcopy.html</ref></li>
 
<li>Use [[Copy-Files-in-Command-Prompt#ROBOCOPY_sub|{{samp|ROBOCOPY}}]] if you're creating backup scripts. {{samp|Xcopy}} has been deprecated and will likely be phased out of use in the near future. {{samp|Robocopy}} can do everything {{samp|xcopy}} can. It is also more flexible and reliable. Creating scripts with {{samp|robocopy}} will future-proof them.</li>
 
<li>Use [[Copy-Files-in-Command-Prompt#ROBOCOPY_sub|{{samp|ROBOCOPY}}]] if you're creating backup scripts. {{samp|Xcopy}} has been deprecated and will likely be phased out of use in the near future. {{samp|Robocopy}} can do everything {{samp|xcopy}} can. It is also more flexible and reliable. Creating scripts with {{samp|robocopy}} will future-proof them.</li>
 
<li>Copy a folder to another location. {{samp|xcopy}}'s main function is to copy folders or the contents of a folder from one location to another. For example, to copy all of the contents of the {{samp| C:\tools}} directory to the new folder {{samp|D:\backup\tools}}, enter the following:
 
<li>Copy a folder to another location. {{samp|xcopy}}'s main function is to copy folders or the contents of a folder from one location to another. For example, to copy all of the contents of the {{samp| C:\tools}} directory to the new folder {{samp|D:\backup\tools}}, enter the following:
Line 65: Line 65:
 
<ul><li>The {{samp|/e}} modifier tells {{samp|robocopy}} to include all subdirectories. This includes empty folders.</li>
 
<ul><li>The {{samp|/e}} modifier tells {{samp|robocopy}} to include all subdirectories. This includes empty folders.</li>
 
<li>{{samp|robocopy}} will automatically copy hidden and system files. It will create new directories if they don't exist at the target location.</li></ul></li>
 
<li>{{samp|robocopy}} will automatically copy hidden and system files. It will create new directories if they don't exist at the target location.</li></ul></li>
<li>Mirror a directory. Mirroring a directory is great for making backups. The mirror option of {{samp|robocopy}} will copy all of the contents from the source to the destination. It will then delete anything at the destination that doesn't exist at the source. This ensures that your backup only has the latest versions of your files. For example, to mirror {{samp|C:\Users\My Documents}} to {{samp|D:\backup\My Documents}}, enter the following:<ref>http://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx</ref>
+
<li>Mirror a directory. Mirroring a directory is great for making backups. The mirror option of {{samp|robocopy}} will copy all of the contents from the source to the destination. It will then delete anything at the destination that doesn't exist at the source. This ensures that your backup only has the latest versions of your files. For example, to mirror {{samp|C:\Users\My Documents}} to {{samp|D:\backup\My Documents}}, enter the following:<ref name="rf18253">http://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx</ref>
 
{{CodeBox|
 
{{CodeBox|
 
<source lang="dos">
 
<source lang="dos">