Software: Windows 7, 8 & 10 | Last modified on 2018-06-18
A guide to copying folders and files using the Command Prompt or PowerShell.
Copy specific folders & files
- Open the Command Prompt (Admin) or PowerShell (Admin).
- Execute xcopy Source/File.txt Destination/File.txt to copy a single file to a new location.
Example: xcopy C:\Users\Documents\File.txt D:\Backup\Documents\File.txt - Execute xcopy Source Destination to copy a folder without the sub-folders to a new location.
Example: xcopy C:\Users\Documents D:\Backup\Documents - Execute xcopy Source Destination /S /I to copy a folder including all sub folders.
Example: xcopy C:\Users\Documents D:\Backup\Documents /S /I - Execute xcopy Source Destination /S /I /H to copy a folder including all sub folders and hidden system folders.
Example: xcopy C:\Users\Documents D:\Backup\Documents /S /I /H - Execute xcopy Source Destination /S /I /R to copy a folder including all sub folders while removing the read-only attributes.
Example: xcopy C:\Users\Documents D:\Backup\Documents /S /I /R - Execute xcopy Source Destination /S /I /O to copy a folder including all sub folders while maintaining all existing permissions.
Example: xcopy C:\Users\Documents D:\Backup\Documents /S /I /O - Execute xcopy Source Destination /D:m-d-y to copy files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
Example: xcopy C:\Users\Documents D:\Backup\Documents /D:03-31-2000