xcopy batch file

https://ss64.com/nt/xcopy.html

Simple backup batch file

Note that long folder names must be enclosed in quotation marks.
@echo off
REM copy documents
xcopy “C:My Documents*.*” d:mirror /c /s /r /d /y /i > d:mirrorxcopy.log
REM copy Outlook data
xcopy “C:Local SettingsApplication DataMicrosoftOutlookoutlook.pst” d:mirror /c /s /r /d /y /i >> d:mirrorxcopy.log

As you can see in the sample code, Xcopy32 introduces many useful switches that didn’t exist in its DOS predecessor. These are the most important ones:
•· /d—This switch copies all source files that are newer than existing destination files. It allows you to update only files that have changed, making the process a lot faster.
•· /c—This command-line option ignores errors. You don’t want one corrupted file to halt the automated copying.
•· /s—This option copies directories and subdirectories.
•· /r—This switch copies read-only files.
•· /y—Use this switch to overwrite files without prompting. You don’t want any user intervention to be required.
•· /i—Use this option to automatically create new folders on destination.

The > d:mirrorxcopy.log suffix creates a log file with all of XCopy’s messages, for later reference and troubleshooting. Using >> appends a file to an existing log rather than creating a new one.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.