All Categories


File Backup XCOPY Arbitrary

With the Windows system comes with a command XCOPY, we can easily through the command prompt window or use Notepad, in the window environment to achieve the menu command inconvenient to achieve the file copy or backup function.

When you back up a file by class, it sometimes involves a different file in a different folder that is backed up according to a condition. If you are involved with a folder structure, it is often necessary to use some dedicated backup Tools to achieve, set up more cumbersome. In fact, both the low-level Windows XP operating system, or more advanced Windows 7, Windows 8 systems, provide a powerful XCOPY command program, with the help of this command, we only need to use the command prompt window directly enter a command , Or write a simple code to write a BAT code, you can arbitrarily carry out their own file backup, compared with the window operation to be much more efficient.

● Case: Quickly back up a class of files

Office of the information file backup disk distribution of many folders, in each folder randomly exist in the number of different, different levels of sub-folders, in these folders stored in TXT, DOC, XSL, PDF, etc. Documents in various formats. When collating the backup file, the leader asks all the PDF files to be identified as editable. How to quickly find these scattered in different parts of the PDF file, and find the file stored in a new folder?

With the help of Windows comes with XCOPY command, in the command prompt window will be able to complete the task. We assume that the MYPDFBAK folder is stored for the E drive.

Start the command prompt window, enter the CD in the Command Prompt window with spaces, and then the command prompt window and resource management window side by side on the desktop, and finally drag the Explorer in the work drive or work folder to this command Window (as appropriate to backup the entire drive or backup a folder), constitute a complete entry into the work of the target command. Enter the command to enter the working drive or folder.

In the command prompt window, execute the following command (Figure 1):


Subsequently, the current drive (or folder) and under the various sub-folders below the PDF type files are copied to the E disk MYDOCBAK folder, and to maintain the original directory structure.

Among them, the parameter / S means that the copy of the specified type of file contains the level of the directory and the various subdirectories (except for the empty directory).

Tip: The above is a copy of the order of a document, if you want to migrate a batch of files, rather than copy the file, then only in Notepad using the migration file command MOVE on it.

● Case: backup by keyword in the file name

A company's file name is required to contain the 'equipment' and 'accessories' and 'material' are marked with the type of material. If only need to be a class of documents (such as 'material' and 'backup', how to write all the files involved in such a backup?

Assuming that the company's document storage directory for the F disk '2012 material supply' backup target for the F disk 'material u0026 rdquo ;. The backup folder is generated as follows:

In the root directory of the F disk with Notepad to create a file (such as 'backup .TXT u0026 rdquo;), in which enter the following command (Figure 2):

XCOPY F: \ 2012 Material Headsu * * Material *. * F: \ Material / S

After the save, the file extension to BAT, get 'copy. BAT' file, double-click the file, in the 'F: \ material' directory will automatically generate all the material class files.

Note: The above order in the * * *. * 'Rarquo; is the use of wildcards to describe all contain' material 'and the words of the document, regardless of' material 'and the words appear in the file name of what location.

● Case: leave a backup file for important files

There are many DLL files in the system catalog that contain system properties and implicit attributes. These files are very important. Once they are damaged by viruses or other programs, the system causes the system to fail. If we can back up these files in advance, if you encounter a system failure, you can use PE to start the system, and then find these files to restore the system. This backup can also be done simply with the XCOPY command.

For example, we want to be in the C drive on the Windows system, all the system properties and hidden attributes of the file backup to the mobile hard disk E: in a directory SYSFILEBAK. The specific implementation process is as follows:

First of all, we use Notepad to build a batch program BAKSYSFILE.BAT, the specific content is as follows (Figure 3):


The command / H in the command line indicates that the file with the hidden attribute is copied, and the system attribute is also copied. / S that contains the system at all levels of subdirectories. * .DLL that all the files on the C drive filter filter.

Copy the batch file to the root directory of the C drive and execute the following, and finally we will get all the important files in the E: \ SYSFILEBAK folder.

● case: at any time automatically resume a large number of documents

If you want to copy all the files on the large capacity hard disk E: \ to F: \ disk, limited to time, can not be completed once, need to complete multiple copies. Or for some reason, the last copy is not complete, suddenly interrupt the copy, and now want to copy. In this case, they can not remember which documents have been copied, which did not copy, how to do?

Very simple, at the command prompt, execute the XCOPY E: \ *. * F: / S / H / D / Y command (Figure 4). It can detect which files are already copied in the past, skip the copy; at the same time to find out which files have not copied the past, immediately copy. The primary parameter / D: m-d-y in which it works is to copy the files that were changed after the specified date or after the specified date. If no date is provided, only those files whose source time is more than the target time are copied.

● Case: Skip the copy error prompt automatically

There is a backup of the situation, we often encounter: whether it is a window copy or at the command prompt operation, in the copy process, because a copy of a file error or the use of this file, and stopped the copy work , If we were not at the time of the computer, then the copy was suspended and will wait until we were intervening.

If we think of this in advance, want to copy the process automatically skip an error file and a file in use and continue to copy other files, the following method can be used.

The specific way is to add the parameters in the XCOPY command / C one, that is, the command line into XCOPY E: \ *. * D: / S / H / D / C / Y on the line (Figure 5). The function of parameter / C is that, even if it is wrong, it continues to copy.

● Case: copy automatically turn off the computer

If the backup copy workload is very large, need to spend a lot of real time backup nas, then just to the off hours, how do? Do you need to wait for overtime? No need to! We can use a simple batch to make XCOPY backup process into automatic replication, and copy the computer after the completion of replication.

To create a new text document, enter the following command (Figure 6) and rename it to XCOPY.BAT.

XCOPY E: \ *. * D: / S / H / C / Y


When you need to back up, double-click XCOPY.BAT to run it, you can go out to work or get off work at this time. The computer will copy the backup file and then automatically shut down.

It can be seen that here is the application of the SHUTDOWN -S command and XCOPY command in conjunction with a skill to complete the backup and automatic shutdown operation.

● Case: Use XCOPY exclusion backup

XCOPY can exclude unwanted files or folders from copying. But this command is not as simple as writing in Windows help. We first look at the help of XCOPY is how to write:

/ EXCLUDE: file1 [+ file2] [+ file3] ...

Specifies a list of files containing strings. Each string must be in a separate line of the file. If any string matches the absolute path of the file to be copied, that file will not be copied.

For example, specifying a string such as \ obj \ or .obj will exclude all files under the directory obj or a file with an .obj extension.

Looking at this help or even the example of it, will you use it? I believe you are still a fog! It's ok! Let us come through the specific case to explain.

We assume that there are two folders, one named DATA, stored in the following table shows the folder or file. A named folder named BACKUP is the destination folder used as a backup filter.



│ ├ ─ plan

│ └ ─ Summary

│ plan .TXT

│ Summary .TXT

│ 1. plan

│ 2. Summary

│ 3. plan

│ 4. Summary

│ 5. Summary


Assuming that our backup target is to copy all the folders and files copied to the BACKUP directory, and exclude the files and directories that have been tagged with the plan.

We only need to execute the following order to achieve the purpose (Figure 7):


One of the text list file UNCOPY.TXT inside, we want to exclude the files and folders you want to exclude, this file we need to save another save, the specific contents are as follows:


Plan .TXT


The use of this case there is a very practical application: For example, you have a file on your hard disk is damaged, you want to back up the hard disk, you can use this method to avoid the damaged file.

About the Author


My name's Casie Terrill but everybody calls me Casie.
I'm from France.
I'm studying at the college (3rd year) and I play the Saxhorn for 3 years. Usually I choose songs from my famous films :).
I have two sister. I love Target Shooting, watching movies and Shortwave listening.

Should you loved this post and you would like to receive more info relating to real time backup nas please visit the website.

Most Viewed - All Categories