Purpose:Synchronize two directories

 

Format:SYNC [/A:... /C /D /E /F /G /J /K /L /M /N[enrst] /O /O:[-]adegnrstu /P /Q /R /S[[+]n] /T /V /W /X /Y /Z] dir1 dir2

 

dir1First directory (and source for a /W)
dir2Second directory (and target for a /W)

 

/A:...

Attribute switch

/O

Only if no target file

/C.

Changed source files

/O:...

Sort order

/D

Copy encrypted files

/P

Prompt

/E

No error messages

/Q

Quiet

/F

No empty subdirectories

/R

Replace

/G

Display percentage completed

/S

Subdirectories included

/H

H(idden included)

/T

Totals

/I"text"

Match description

/V

Verify

/J

Restartable copy

/W

Delete non-matching target

/K

Keep RDONLY attribute

/X

Clear archive bit

/L

ASCII-mode FTP transfer

/Y

Suppress prompt

/M

Modified files (not Archived)

/Z

Overwrite read-only

/N

Disable



 

See also: COPY and MOVE.

 

File Selection

 

Supports command dialog, extended wildcards and ranges.

 

Internet: Can be used with FTP servers.

 

Usage:

 

SYNC will synchronize two directories, copying the updated files from each directory to the other. If you don't specify any arguments, SYNC will display its command dialog.

 

SYNC sets three internal variables:

 

%_sync_dirsThe number of directories created
%_sync_filesThe number of files copied
%_sync_errorsThe number of errors

 

Options:

 

/=Display the SYNC command dialog to help you set the directory and command line options. You cannot specify any other arguments on the command line.

 

/A:...Select only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:. See the cautionary note under Advanced Features above before using /A: when both dir1 and dir2 contain file descriptions. Hidden or system files selected by this option overwrite hidden or system files in the target directory.

 

You can specify /A:= to display a dialog to help you set individual attributes.

 

/CCopy files only if the destination file exists and is older than the source file. This option is useful for updating the files in one directory from those in another without copying any files not already in the target directory.

 

/DForce copy of an encrypted file even when the target will be decrypted.

 

/ESuppress all non-fatal error messages, such as File not found or Can't copy file to itself. Fatal error messages, such as Drive not ready, will still be displayed. This option is most useful in batch files and aliases.

 

/FWhen used with /S, SYNC will not create any empty subdirectories.

 

/GDisplays the percentage copied, the transfer rate (in Kbytes/second), and the estimated time remaining. Useful when copying large files across a network or via FTP to ensure the copy is proceeding. When /V is also used, reports percentage verified.

 

/HCopy all matching files including those with the hidden and/or system attribute set. See the cautionary note under Advanced Features above before using /H when both dir1  and dir2 contain file descriptions.

 

/I"text"Select source files by matching text in their descriptions. See Description Ranges for details.

 

/JCopy the files in restartable mode. The copy progress is tracked in the destination file in case the copy fails. The copy can be restarted by specifying the same source and destination file names.

 

/K(Keep read-only attribute)  SYNC normally maintains the hidden and system attributes, sets the archive attribute, and removes the read-only attribute on the target file. /K tells SYNC to also maintain the read-only attribute on the destination file.

 

/LPerform FTP transfers in ASCII mode, instead of the default binary mode.

 

/MCopy only those files with the archive attribute set, i.e., those which have been modified since the last backup. The archive attribute of the source file will not be cleared after copying; to clear it use the /X switch, or use ATTRIB.

 

/NDo everything except actually perform the copy. This option is useful for testing the result of a complex SYNC command. /N displays how many files would be copied. /N does not prevent creation of destination subdirectories when it is used with /S.

 

A /N with one or more of the following arguments has an alternate meaning:

 

dSkip hidden directories (when used with /S)
eDon't display errors
jSkip junctions (when used with /S)
nDon't update the file descriptions
rA SYNC /W will delete to the recycle bin (unless the file matches the RECYCLEEXCLUDE environment variable).
sDon't display the summary
tDon't update the CD / CDD extended directory search database (JPSTREE.IDX)

 

/O:...Sort the files before processing.

 

You may use any combination of the sorting options below. If multiple options are used, the listing will be sorted with the first sort option as the primary key, the next as the secondary key, and so on:

 

nSort by filename and extension, unless e is explicitly included. This is the default.
-Reverse the sort order for the next sort key
aSort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension.
dSort by date and time (oldest first); also see /T:acw
eSort by extension
gGroup subdirectories first, then files
rReverse the sort order for all options
sSort by size
tSame as d
uUnsorted

 

/PAsk the user to confirm each copy and delete. Your options at the prompt are explained in detail under Page and File Prompts. See also: the /Q option below.

 

/QDon't display filenames, percentage copied, total number of files copied, etc... When used in combination with the /P option above, it will prompt for filenames but will not display the totals. This option is most often used in batch files. See also /T.

 

/RPrompt the user before overwriting an existing file. Your options at the prompt are explained in detail under Page and File Prompts.

 

/SCopy the subdirectory tree starting with the files in the source directory plus each subdirectory below that. If the destination subdirectories don't exist, SYNC will attempt to create them. If SYNC /S creates one or more destination directories, they will be added automatically to the extended directory search database.

 

 If you attempt to use SYNC /S to copy a subdirectory tree into part of itself, SYNC will detect the resulting infinite loop, display an error message and exit.

 

 If you specify a number after the /S, SYNC will limit the subdirectory recursion to that number. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only affect the "a", "b", and "c" directories.

 

If you specify a + followed by a number after the /S, SYNC will not sync any files until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not sync anything in \a or \a\b.

 

/TTurns off  the display of filenames, like /Q, but does display the total number of files copied.

 

/VVerify each disk write by performing a true byte-by-byte comparison between the source and the newly-created target file. This option will significantly increase the time necessary to complete a SYNC command.

 

/WDelete files in dir2 that do not exist in dir1.

 

/XClear the archive attribute from the source file after a successful copy.

 

/YIf you have the COPY Prompt on Overwrite option set, you can suppress the prompt with /Y.

 

/ZOverwrite destination files regardless of their attributes. Without this option, SYNC will fail with an "Access denied error" if the destination file has its read-only attribute set, or  (depending on other options) its hidden or system attribute set. Required to overwrite read-only targets regardless of other options. Required to overwrite hidden or system targets unless the source also has the attribute, and either /H or /A: is used to select it.