SYNC |
Purpose: | Synchronize two directories |
Format: | SYNC [/= /A:... /C /D /DD /E /F /G /J /K /L /M /N[enrst] /O /O:[-]acdeginorstuz /P /Q /R /S[[+]n] /T /V /W /X /Y /Z] dir1 dir2 |
dir1 | First directory (and source for a /W) |
dir2 | Second directory (and target for a /W) |
/A:... |
Attribute switch |
Only if no target file |
|
/C. |
Changed source files |
/O:... |
Sort order |
Copy encrypted files |
Prompt |
||
/DD |
Remove empty subdirectories |
Quiet |
|
No error messages |
Replace |
||
No empty subdirectories |
Subdirectories included |
||
Display percentage completed |
Totals |
||
H(idden included) |
Verify |
||
Match description |
Delete non-matching target |
||
Restartable copy |
Wait between block copy |
||
Keep RDONLY attribute |
Clear archive bit |
||
ASCII-mode FTP transfer |
Suppress prompt |
||
Modified files (not Archived) |
Overwrite read-only |
||
Disable |
|
|
File Selection
Supports 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_dirs | The number of directories created |
%_sync_files | The number of files copied |
%_sync_errors | The number of errors |
Example:
Synchronize the directories C:\MyData and D:\MyData, including subdirectories (but not empty subdirectories), and delete any files in D:\MyData that don't exist in C:\MyData:
sync /S /F /W C:\MyData D:\MyData
Options:
/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.
/G | Displays 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. |
/I"text" | Select source files by matching text in their descriptions. See Description Ranges for details. |
/J | Copy 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. |
/M | Copy 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. |
/N | Do 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:
d | Skip hidden directories (when used with /S) |
e | Don't display errors |
j | Skip junctions (when used with /S) |
n | Don't update the file descriptions |
r | A SYNC /W will delete to the recycle bin (unless the file matches the RECYCLEEXCLUDE environment variable). |
s | Don't display the summary |
t | Don't update the CD / CDD database (JPSTREE.IDX) |
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:
n | Sort by filename and extension, unless e is explicitly included. This is the default. |
- | Reverse the sort order for the next sort key |
a | Sort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension. |
c | Sort by compression ratio |
d | Sort by date and time (oldest first); also see /T:acw |
e | Sort by extension |
g | Group subdirectories first, then files |
i | Sort by description |
o | Sort by owner |
r | Reverse the sort order for all options |
s | Sort by size |
t | Same as d |
u | Unsorted |
z | Same as s |
/P | Ask 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. |
/Q | Don'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. |
/R | Prompt the user before overwriting an existing file. Your options at the prompt are explained in detail under Page and File Prompts. |
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.
/T | Turns off the display of filenames, like /Q, but does display the total number of files copied. |
/Z | Overwrite 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. |