How To Copy Files and Backup With Xcopy In Windows? – POFTUT

How To Copy Files and Backup With Xcopy In Windows?

Windows provides very featureful command which is used to copy files can take backups named xcopy . Xcopy can be used copy files from one partition to other partition or a usb drive. Xcopy also supports  incremental backup which create advantages  while taking backups. We will look different usage examples of xcopy in this tutorial.


Detailed help about xcopy command can be show with /? option like below.

$ xcopy /?

Copy Files

One of the most used type of xcopy is  providing no option and just copying files from source path to the destination file. In this example we will provide source file named systeminfo.txt to the Downloads directory.

$ xcopy systeminfo.txt Downloads
Copy Files
Copy Files

Ignore Errors

While copying files there may some errors related permission, corrupt data, changed data etc. These will create errors and these error will be printed to the terminal by default and these errors can be interrupt the copy operation. These errors can be ignored with /c option.

$ xcopy /c systeminfo.txt Downloads

Backup Data Using Date and Time Stamp

One of the very useful feature is copying files according to their date and time stamp. While we are making backups regularly we can specify time which files those are changed specified time to backup. For example we take backup in following periodic dates.

  • 01-04-2017
  • 08-04-2017
  • 15-04-2017

We can specify date where we will only copy files changed after that time. In this example only files those changed after 15-04-2017 will be copied.

$ xcopy \project \project-backup /d:15-04-2017

Verbose Operation

Other useful feature is printing files during copy operation. This will give us feedback about the copy operation. We will use /f option for this.

$ xcopy /f Downloads Downloads-backup
Verbose Operation
Verbose Operation

Copy Only Files Existing Destination

While copying files from source to the destination we can set a rule which will only copy the files existing in remote destination.

$ xcopy /u Downloads Downloads-backup

Copy Hidden and System Files

Windows have different type of files attributed like System and Hidden . These files especially used by operating system or related applications. These files are not copied by default. In order to copy these type of files we will provide /h

$ xcopy /h Downloads Downloads-backup

 Exclude Files and Extension For Copy

While copying we may need to not copy some file names or extensions. For example a developer do not want to copy binary or temporary files. So we need to exclude these type of files and file names. We will create a file which stores file names and extensions line by line those will be excluded. We have a file ex.txt which have following contents.


We want to exclude .exe and temp file names and extensions

$ xcopy /exclude:ex.txt Downloads Downloads-backup

LEARN MORE  How To Print/Get Today Date and Time In JavaScript, C/C++, Python, C#, Java, PHP, PowerShell, Excel (VBScript) ?

Leave a Comment