DIRCMP
— Compare two
directories.
Syntax:
DIRCMP
/A /C /D /M /P /R /S /T /X
dir1
dir2
/A | compare attributes of items which exist in both dir1 and dir2 |
/C | compare file contents |
/D | disable highlight |
/M | do not display the footers |
/P | page output |
/R | compare directories recursively |
/S | compare sizes of files which exist in both directories |
/T | compare time stamps of files which exist in both directories |
/X | reverse operation — reports only items which exist in both directories |
dir1 | the first directory; directory aliases are supported |
dir2 | the second directory; directory aliases are supported |
dir1 and dir2 are both required. Wildcards are not allowed; you must name two unambiguous directories.
/A
compares attributes when a file or
subdirectory exists in both dir1 and
dir2. Only the read-only, archive, hidden, and
system attributes are compared. The more exotic attributes will be ignored.
/C
compares the contents of files which
appear in both directories. Both files are opened, then data is read and
compared, byte-for-byte. This option can slow DIRCMP
down
considerably! If the command is unable to read from either file, the files
are considered the same.
/S
compares file sizes when a file exists
in both locations. Only files are tested. The relevant Windows APIs do not
report sizes for subdirectories.
/T
compares time stamps when a file
exists in both locations. Only the last-write time stamp is compared, and the
comparison is fuzzy; differences of less than two seconds may be ignored. Only
time stamps of files are compared; this option does not test
subdirectories.
/X
reverses DIRCMP
’s
operation and reports only items which exist in both locations. If you combine
/X
with /A
, /C
, etc. then only
items with matching attributes, contents, and so on will be listed.
Note that /R
, not /S
,
controls recursion. Recursion is only performed where subdirectories with the
exact same name exist in both dir1 and
dir2.
Mismatches are reported with a note in brackets:
[1] | The item exists in dir1 but not in dir2. |
[2] | The item exists in dir2 but not in dir1. |
[A] | The item has different attributes in dir1 and dir2. |
[C] | The file has different contents in dir1 and dir2. |
[S] | The file has different sizes in dir1 and dir2. |
[T] | The item has different time stamps in dir1 and dir2. |
The letters may be combined; e.g. [ST]
would mean that
the items have different sizes and time stamps.
Items which exist in one directory, but not the other, are always reported. There is no option to suppress this feature.
If a file exists in dir1 and a subdirectory of the same name exists in dir2 — or vice versa — then both will be reported as mismatches.
dircmp /r /s "%userprofile\Documents" d:\backup\docs\