XXTB #99 ... Revision History of XXCOPY
[ Back to Table of Contents ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #01
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: XXCOPY Command Parameters Reference
Date: 2007-03-10 Revised for ver 2.95.1
====================================================================
Basic Command Parameter Syntax:
XXCOPY source destination (simplified syntax)
In its simplest form, XXCOPY takes two parameters,
from WHERE to WHERE
This very intuitive command syntax has its root in the COPY command
introduced in 1981 as a PC-DOS (MS-DOS) built-in command.
The first parameter is the source specifier and the second one is
the destination specifier. These two parameters must be in this
order. As common to the COPY and XCOPY command syntax, the
destination specifier can be omitted. Then, by default, the
current directory in the current drive becomes the destination.
XXCOPY source [ destination ]
By convention, an optional parameter is denoted in the syntax
definition with a pair of square-brackets surrounding it.
In addition, you may add command switches (which are also called
options) to customize XXCOPY's behaviors. It is the extensive
set of switches that make XXCOPY so versatile and powerful.
Full Command Parameter Syntax:
XXCOPY source [ destination ] [ switches... ]
All switches start with a slash (/) character whereas the source
and the destination specifiers do not have the slash(/) prefix.
The source and the destination specifiers must be separated from
other items in the command line by at least one blank (space or tab)
character. On the other hand, you may omit blank characters between
switches in order to minimize the total length of the command line.
Example:
XXCOPY C:\mydir\ D:\yourdir\ /S /H
Here, "C:\mydir\" is the source specifier and "D:\yourdir\" is
the destination specifier. They do not start with a slash (/).
It has two (/S and /H) switches.
Note that the positions of the switches need not be at the end of
the command line. Switches may begin even before the source specifier.
The order of the switches is not generally important except when
conflicting switches are specified, the rightmost switch will
prevail. More rules for special cases are discussed at the end
of this article. For a complete syntax and semantics for the
source specifier, see XXTB #04.
-------------------------------------------------------------
Caution to DOS novices:
The blank characters (space or tab) act as the delimiter of
the arguments. Therefore, a name with embedded space must
be surrounded by a pair of quotes (") to be kept unbroken.
XXCOPY C:\My Documents\ D:\backup\ // bad
XXCOPY "C:\My Documents\" D:\backup\ // good
This is true for nearly all command line applications.
-------------------------------------------------------------
Once you learn this simple rule, it is quite easy to understand a
long XXCOPY command line.
XXCOPY switches:
Here, a first time XXCOPY user may be overwhelmed by the sheer
number of the switches. Since the power of XXCOPY comes from
these switches, you have to learn to live with them. We try
our best to keep these (still increasing) switches under control.
Since the number of switches far exceeds the available alphabet,
many of the switches use multiple characters. For better or worse,
the syntax adheres to the original XCOPY's syntax very closely.
It is a mixed blessing, for sure. So, when we feel very strongly,
we took liberty in making improvements in a few exceptional cases.
But, overall, if you are very familiar with how XCOPY works, there
will be very little surprise for you.
Let us just take a look at the full list of XXCOPY switches with
a terse comment on each. For most switches, full explanation will
be given later.
for Command Line Syntax XXTB #25
for Command Reference Alphabetic Listing XXTB #26
for Command Reference Functional Classification XXTB #27
for The Wild-Wild-Source Specifier XXTB #28
----- The following switches use file attributes to select files -----
/A Same as /ATA. Copies only files with the archive attribute set.
Doesn't change the attribute.
/M Copies only files with the archive attribute set.
Turns off the archive attribute.
/AT<mask> Selects files by the attribute bits (AHSRC).
You may use two or more /AT<mask> switches to specify multiple
attributes required. E.g., /ATA/ATH qualifies files with both
the A(rchive) bit and the H(idden) bits.
Or, you may use one /AT<mask> switch with multiple letters to
select alternative attribute bits to select files. E.g.,
/ATAH qualifies a file which has either A-bit, H-bit or both.
/AX<mask> Excludes files with the specified attribute bits (AHSRC).
You may use two or more /AX<mask> switches to specify
attribute bits to exclude files for file operations. E.g.,
/AXA/AXH excludes files with A-bit, H-bit, or both.
Or, you may use one /AX<mask> switch with multiple letters to
exclude files with only the specified combination of attribute
bits. E.g., /AXAH excludes files with both A-bit and H-bit.
Note: The /AT<mask> and /AX<mask> switches have opposite conjugation
rules (the effects of combining attribute bits --- AND and OR).
/A0 Cancels *ALL* /A, /M, /AT, and /AX switches.
----- The following switches modify the file attributes -----
/AA Sets the src file archive bit (without actually copying).
/AZ Clears the src file archive bit (without actually copying).
Note: Both /AA and /AZ implicitly set /H (can be overridden).
/AC Copies specified files irrespective of the archive attribute.
Turns off the archive attribute after XXCOPY is done.
/AN<mask> Sets a new value to file attribute bits (replace the value).
The <mask> value is a combination of letters, AHSRC.
/AR<mask> Resets file attribute bits (clears specified bits).
/AS<mask> Sets file attribute bits (sets specified bits).
Note: The <mask> value for /AR and /AS specifies attributes (AHSRC)
whose bits are either reset or set respectively to the existing
file attributes. Unspecified attributes bits are kept unchanged.
/ARD<mask> Resets directory attribute bits (clears specified bits).
/ASD<mask> Sets directory attribute bits (sets specified bits).
/ARD and /ASD work on directories analogous to /AR and /RS.
Note: The /AA, /AN, /AR, /AS, /ARD, /ASD, and /AZ switches modify the
file attributes without copying the files to the destination,
whereas the /A, /AT and /AX switches select files by the file
attributes for various operations (copy, list, remove, etc.).
----- The following switches use other file attribute bits -----
/H Copies hidden and/or system files also.
/H0 Excludes hidden and/or system files (default).
/Ho Copies hidden and/or system files only.
/R Overwrites read-only files.
/K0 Keeps H-bit and S-bit, sets A-bit, clears R-bit (default).
/K Keeps the source attributes including read-only (same as /KS).
/KS Keeps the source attributes including the read-only bit.
/KD Keeps the attributes of destination (overwritten) file.
/KN Sets the destination attributes to normal (only /A).
(File attributes are discussed in XXTB #06)
----- The following switches are useful for backup and archive -----
/BI Backs up incrementally, different (by time/size) files only.
/BB Backs up brand new files only (does not overwrite existing ones).
/BN Backs up newer files only (includes brand new files).
/Bo Backs up older files only (includes brand new files).
/BX Backs up different-date files (includes brand new files).
/BZ Same as /BZX.
/BZE Backs up equal-size files (includes brand new files).
/BZL Backs up larger-size files (includes brand new files).
/BZS Backs up smaller-size files (includes brand new files).
/BZX Backs up different-size files (includes brand new files).
/BE Backs up exactly the same files(includes brand new files).
/BS Selects exactly the same files (this is useful with /RS).
/BU Standard Backup switch (same as /r/i/bi/q/c/h/e/v/y).
/B0 Undo any of /BI, /BB, /BN, /Bo, /BX, or /BZ switches.
/U Updates the files that already exist in destination.
Note: A "brand new" file refers to a file which exists in the
source directory but not in the destination directory
(Micrososoft's Robocopy call it a "lonely file").
/SP Spans the copy job over multiple destination (new volume).
Note: /SP cannot be used with switches which reference the
destination for file selection --- that is, the /Bxx
(backup) switches, and /U will be disabled by /SP.
That is, the spanning of the destination volume by /SP
assumes the backup operation is a full backup without
referencing the files already on the destination.
----- The following switch adds inclusive alternate templates -----
/IN<tmpl> Includes an alternate filename template (tmpl).
You may specify as many alternate filename patterns as you want.
The template must be for the "Lastname" of the source specifier
(no backslash in the template, but wildcard characters are OK).
----- The following switches exclude directories or files -----
/X<xspec> Adds an exclusion specifier (xspec) (see below for exclusion).
/EX<xlist> Specifies a text file which contains a list of xspecs (see below).
<xspec> Exclusion item for /X and the file contents specified by /EX.
. The text file may contain an arbitrary number of xspecs which
are separated by space, tab, or newline characters.
. An xspec with embedded spaces must be surrounded by a pair
of double-quote characters(").
. An xspec cannot span from one line to another.
. Two consecutive colons (::) or slashes (//) start a comment
field which ends at the end of the line.
. You may specify more than 1 exclusion file. In such a
case all of the exclusion files will be processed.
Exclusion specifier (xspec) syntax (consists of up to 3 parts):
for file, [ dir_spec\ ] [ *\ ] [ ftemplate ]
for dir, [ dir_spec\ ] [ *\ ] [ dtemplate ]
dir_spec is always followed by a backslash (\). It specifies
a directory (or directories with wildcard) which
are relative to the source directory unless it
starts with a \. A wildcard specifier is allowed
only in the last element of dir_spec.
*\ This second part specifies that the exclusion
applies to all subdirectories under dir_spec.
ftemplate File_template, must not contain backslash (\).
It may contain wildcard characters (* and/or ?).
dtemplate Directory_template, the template must be terminated
by one of the following four ending (three types)
dirname\*\* full directory
dirname\ full directory (same as dirname\*\*)
dirname\* partial directory, files only
dirname\?\* partial directory, subdirs only
The dirname part may have wildcards (* and/or ?).
Any of the three parts can be omitted.
There are 11 classes in xspecs as follows.
D dir_spec\ftmpl H dir_spec\*\ftmpl
A dir_spec\* E dir_spec\dtmpl\* I dir_spec\*\dtmpl\*
B dir_spec\?\* F dir_spec\dtmpl\?\* J dir_spec\*\dtmpl\?\*
C dir_spec\*\* G dir_spec\dtmpl\*\* K dir_spec\*\dtmpl\*\*
If dir_spec is omitted, the file_template applies to all subdirs.
XXCOPY optimizes the exclusion parameter by eliminating
some redundant specifiers.
Use "/W/oX" with xspec to test the syntax.
See XXTB #05 (The Exclusion specifier).
----- The following switches limit files by the filetime -----
/D Same as /DA.
/DA Copies newer files and brand new files.
/DB Copies older files and brand new files.
/DS Copies only the files whose filetime is exactly the same.
/DX Copies only the files whose filetime is different in any way.
Note: All filetime comparisons are affected by the fuzzy range (/FF).
/D:<date> Same as /DA:<date>.
/DA:<date> Copies files that were changed on or after the specified date.
/DB:<date> Copies files that were changed on or before the specified date.
/Do:<date> Copies files that were changed on the specified date.
/DA#<n> Copies files that were changed on or after <n> days ago.
/DB#<n> Copies files that were changed on or before <n> days ago.
/Do#<n> Copies files that were changed on the day <n> days ago.
Note: A "brand new" file refers to a file which exists in the
source directory but not in the destination directory
(Micrososoft's Robocopy call it a "lonely file").
Note: With /DA#<val>, /DB#<val> and /Do#<val>, the parameter <val> will
be treated as the number of Days unless it is appended with a
one-letter suffix (D, H, M, or S which stand for Days, Hours,
Minutes, or Seconds, respectively). When <val> is given in
the number of days, the exact time is midnight of the day.
e.g., /DA#0 denotes files made some time today after midnight.
/Do#2 means all day the day before yesterday.
/DA#30m selects files made within the last 30 minutes.
/DA:. Copies files that were changed today or later (same as /DA#0).
/DB:. Copies files that were changed yesterday or earlier.
/Do:. Copies files that were changed today only.
/DA:<val> and /DB:<val> work as a pair if both are specified.
e.g., /DA:1997-01-01 /DB:1997-12-31 files made in 1997
/DA:1997-04-01 /DB:1997-04-30 files made in April 1997
/DB:1997-03-31 /DA:1997-05-01 exclude files made in April
/DA:1997-01-01 /DB:1997-01-01 try the shorter /Do:1997-01-01
Since the US and European conventions are not reconcilable,
we recommend the ISO 8601 standard (YYYY-MM-DD) with a 4-digit
year value followed by month and day. If all values have
2 digits only, it is interpreted according to the system setting.
A file date must be between 1970-01-01 and 2069-12-31.
A partial date specifier is accepted for /DA:, /DB: and /Do:
where yyyy-mm and yyyy denote the month and year respectively.
E.g., /Do:2000-2 is equivalent to /DA:2000-2-1 /DB:2000-2-29,
and /DB:1999 to /DB:1999-12-31, and /DA:2000 to /DA:2000-1-1.
/DA:<time> Same as /DA:<date> except an additional time value may be added.
/DB:<time> Same as /DB:<date> except an additional time value may be added.
The <time> parameter starts with the <date> (as shown above)
followed by 'T' or '@' and hh:mm:ss, hh:mm, or hh.
e.g., 2002-10-25T15:25:30 (recommended as ISO 8601 std)
31-10-2002@13:00 10-31-2002@13 (min and sec may be omitted)
(/D0:<date> cannot be specified with the <time> value).
Note: /DA, /DB, /DX, /DS, /Do, /DA:<date> and /DB:<date> are mutually
exclusive (except /DA:<date> and /DB:<date> work as a pair).
Note: /DA and /DB, if date is omitted, are the same as /BN and /Bo,
respectively, except that /DA and /DB can be combined with another
/Bxx switch (e.g., /BI) where as /BN and /Bo cannot (in the same group).
Note: /DA, /DB, /DX and /DS compare source and destination files using
both date and time whereas /DA:<date> and /DA#<n> use date only.
/D0 Cancels all file-date related (/D...) switches.
----- The following switches modify filetime semantics -----
/FW Uses the Last-Write timestamp for the Filetime comparison (default).
/FA Uses the Last-Access timestamp for the Filetime comparison.
/FC Uses the Creation timestamp for the Filetime comparison.
Note: /FW, /FA and /FC are mutually exclusive choices.
/FL Filetime in Local time (default).
/FU Filetime in UTC(Universal Coordinated Time - same as GMT).
Note: /FL and /FU are mutually exclusive choices.
Note: The word "Filetime" (or sometimes, "Filedate") is used
in the context of comparing the time value associated
with a file against another time value (e.g., in /DA, /BN)
and XXCOPY uses only one of the three timestamps that
are attached to a file (by the /FW, /FA or /FC switch).
/FF Fuzzy Filetime (same as /FF2S --- matches within 2 sec).
/FF0 Fuzzy Filetime cancelled (adjustment value set to +/- 0).
/FF<val> Fuzzy Filetime, adjust ref time +/- <val> seconds.
/FF+<val> Fuzzy Filetime, adjust ref time by adding <val> seconds.
/FF-<val> Fuzzy Filetime, adjust ref time by subtracting <val> seconds.
Note: With /FF<val>, /FF+<val> and /FF-<val>, the parameter <val> will
be treated as the number of seconds unless it is appended with a
one-letter suffix (D, H, M, or S which stand for Days Hours,
Minutes, or Seconds, respectively).
e.g., /FF treats file times within +/- 2 sec as the same.
/FF-1H treats files older by up to 1 hour as the same.
/FF+2/FF-4 (you may choose asymmetric slack values).
Note: The /FF switch affects all filetime comparisons such as /CLONE,
/BI, /BU, /BS, /BX, /BO, /BN, /DA, /DB, /DS, /DX, /TS, and /TD.
Note: The FAT (DOS/Win9x) file system has a 2-second granularity in
file time whereas NTFS, Unix and other file systems use finer
time stamps. The /FF switch is useful for incremental backup
between volumes of different file systems.
/FT Legacy switch; replaced by /FF+2.
/FR Legacy switch; replaced by /FF-2.
----- The following switches cope with time zones -----
/TS+<n> Adds an offset (Hr) to the time of source (and the copied ) file.
/TS-<n> Subtracts an offset (Hr) from source (and the copied) file.
/TD+<n> Adds an offset (Hr) to the time of the destination file.
/TD-<n> Subtracts an offset (Hr) from the dst file for comparison.
Note: The offset value <n> for /TS and /TD is specified in hours
unless it is appended with a one-letter suffix (D, H, M, or S
which stand for Days, Hours, Minutes, or Seconds respectively).
----- The following switches control timestamps -----
/TTA Touches (modifies) timestamp of Last Access of src.
/TTA0 Preserves timestamp of Last Access of src (default).
/TCA Copies the timestamp of Last Access fm src to dst.
/TCA0 Uses current time for dst Last Access (default).
/TCC Copies the timestamp of Create Time fm src to dst.
/TCC0 Uses current time for dst Create time (default).
/TCW Copies the Last Write time fm src to dst (default).
/TCW0 Uses current time for dst Last Write time.
----- The following switches qualify the source by file size -----
/SZ:<n>-<m> Copies a file whose size is between n bytes and m bytes.
/SZ:<n>- Copies a file whose size is equal to or greater than n bytes.
/SZ:-<m> Copies a file whose size is equal to or less than m bytes.
/SZ:<n> Copies a file whose size is exactly n bytes.
/SZ!<n>-<m> Copies a file whose size is NOT between n bytes and m bytes.
/SZ!<n>- Copies a file whose size is NOT equal to or greater than n bytes.
/SZ!-<m> Copies a file whose size is NOT equal to or less than m bytes.
/SZ!<n> Copies a file whose size is NOT equal to n bytes.
/SZ:- Disables size-based selection (/SZ!- also works).
Note: The size values <n> and <m> are entered in bytes unless appended
with a suffix letter (K, M, or G which stands for metric kilo
(x1000), mega (x1000000), or giga (x1000000000) respectively).
/SZ<n> Legacy switch; replaced by /TR<n>.
----- The following switch limits the destination file size -----
/TR<n> Truncates the new file to (copies the first) n bytes.
Note: The TR<n> switch replaces the legacy SZ<n> switch.
----- The following switches deal with subdirectories -----
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E.
/T Creates directory structure, but does not copy files. It copies
all directories including empty ones (implicitly sets /E).
/SG Same as /SGN (see variations in handling duplicates below).
/SGF Gathers files into one-level directory (unsorted First file 1st).
/SGN Gathers files into one-level directory (sorted, Newest file 1st).
/SGo Gathers files into one-level directory (sorted, Oldest file 1st).
/SGFo Gathers files into one-level directory (First only).
/SGNo Gathers files into one-level directory (Newest only).
/SGoo Gathers files into one-level directory (Oldest only).
/SG0 Cancels file-gather switches (/SG...).
/SL Flattens subdirectories, add-name-Left (see below).
/SX Flattens subdirectories, add-name-Middle (see below).
/SR Flattens subdirectories, add-name-Right (see below).
/SL, /SX, and /SR are the same as /S except the output files
will be saved as a flat directory without adding levels of
subdirectories. The source subdirectory name will become a
part of the target filename. /SL and /SR add the subdir name
to the left or right of the name respectively.
/SX inserts the subdirectory name in the middle.
/SLR Rebuilds flattened directory (path to the left).
/SXR Rebuilds flattened directory (path in the middle).
/SRR Rebuilds flattened directory (path to the right).
/SLR /SXR, and /SRR do opposite of /SL, /SX and /SR respectively.
/S<d> Sets the directory delimiter character for /SL, /SX and /SR,
where <d> is any legal non-alphabetic, non-blank character.
The default delimiter is back-apostrophe (`).
/DL<n> Limits processing of directory nesting to n levels.
/DL0 removes the limit. /DL works only when /S or /E is set.
----- The following switches check the destination directory -----
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory (no prompting).
Note: when the destination specifier ends with a backslash,
it declares as a directory which implicitly sets the /I switch.
/IA Continues if destination is absent (terminates if exists).
/IA<item> Continues if the specified item (file/directory) is absent.
/IP Continues if destination is present (terminates if absent).
/IP<item> Continues if the specified item (file/directory) is present.
/ILD<label> Continues if the destination volume label matches as specified.
/ILS<label> Continues if the source volume label matches as specified.
/Z Deletes extra files or subdirectories in destination.
/ZY Same as /Z except there is no confirmation prompt.
----- The following switches control the prompting behaviors -----
/P Prompts you before creating each destination file.
/PC Prompts you before creating new files.
/PC0 Suppresses warning on file-creation.
/PD Prompts you before starting each directory with options for...
Y (Yes), N (No), A (All), R (Remaining dirs), S (This & subdirs).
/PN Prompts when on excessive failures on /NX operations.
/PN0 Suppresses prompts on excessive failures of /NX operatoins.
/Po Prompts you before overwriting existing files (default).
/Po0 Suppresses warning on file-overwrite (Legacy /Y).
/PZ Prompts you for confirmation of the dst (for /CLONE /Z /ZY).
/W Same as /WS.
/WS Prompts you to press a key at the start of copying.
/WS<n> Waits at the start of operation for a specified period (n sec).
/WE Prompts you to press a key at the end of copying.
/WE<n> Waits at the end of the operation for a specified period (n sec).
/WD0 Suppresses warning for copying a non-directory source.
/WD Prompts with a warning for copying a non-directory src (default).
/WV0 This switch is now obsolete and has no effect.
/WV This switch is now obsolete and has no effect.
/C Continues copying even if errors occur (default).
/C0 Disables the /C switch (terminates upon error).
/CB Continues batch file if XXCOPY ended OK last time.
/CBQ Same as /CB except suppresses console output to end immediately.
/CB0 Cancels the /CB and /CBQ switches.
/CE Same as /CBQ/EC (most useful in batch file with @echo off).
/CR<n> Sets the retry period (n seconds, default = 3) on failed copy.
/Y Overwrites existing files without prompting (See /BB).
/-Y Prompts you before overwriting existing files.
/Y0 Same as above (/-Y).
/YY Suppresses ALL prompts unconditionally (good in a batch script).
----- The following switches control Remove (file delete) -----
/RC Removes files in src after a successful copy (equivalent to move)
/RS Removes files in src which qualify (no copying).
/RD Removes files in dst which qualify to be overwritten (no copying)
/RX Removes files in dst which are absent in src (no copying).
/R0 Undo any of /RC, /RS, RD, or /RX switches.
/RCP Prompts on source-file-remove after successful copy (default).
/RCY Suppresses prompts after a successful source-file-remove.
Note: Whereas /Y and /-Y modify prompting for the copy action
of /RC (Remove after Copy) switch, the suffix 'P' or 'Y' controls
the prompt for the file remove action after copy.
Note: The suffix 'P' or 'Y' can also be added to any of /RS, /RD,
or /RX switches which will insert or suppress respective prompt.
For these remove-without-copy switches, the /Y and /-Y switches
also control the prompt for the remove action.
Note: /RX can be thought of a /Z operation without copying files.";
In general, the /RS/BB combination (by swapping src and dst)";
provides more file-selection controls than the /RX switch.";
Note: /PD and /PD0 control additional prompt on each directory.
/RMDIR Removes a directory Same as /RS/S/H/R/PD0/ED0.
----- The following switches control empty directories -----
/ED0 Deletes an empty directory (default)
/ED Preserves the directory even if it becomes empty.
/ED<n> Preserves n levels of empty directories.
Note: These switches are in effect only with file/directory removal
operations (/Z, /RC, /RS, /RD, /RX, and /CLONE cases).
----- The following switches control cyclic directory copy -----
/CC0 Disallows cyclic copy (src includes the dst directory).
/CC Warns a cyclic copy with a Y/N prompt.
/CCY Allows a cyclic copy by excluding the dst from src (default).
----- Filename pattern matching -----
/N Uses the short (8.3) name for name matching, and creation.
/N0 Disables /N and /NP (default, uses longname when applicable).
/NP Uses precise name matching (ignores match in alias).
/NP0 Uses loose name matching (default, longname or shortname match).
/NX Preserves the shortname when the file is copied.
/NX0 Disables the /NX (shortname preservation) feature.
Note: /N, /NP, and /N0 are mutually exclusive.
Note: If src and dst are both local drive, the shortname will be
preserved (/NX) by default, but if either src or dst is
specified by a UNC (starts with \\), /NX0 is default.
/NL Renames longname to match the source (No copy operations).
/NS Renames shortname to match the source (No copy operations).
/NC0 Disables /NCL, /NCU, or /NCX (accepts letters of both cases).
/NCU Uses Uppercase-only name when a new file is created.
/NCL Uses Lowercase-only name when a new file is created.
/NCX Uses Uppercase-only name when a new short-name file is created.
/NW Uses the new (Win32) wildcard matching scheme.
/ND Uses the old (DOS) wildcard matching scheme.
Note: /ND and /NW are mutually exclusive choices.
----- The following switches terminate when a quota is met ----
/QF Quits when the quota for the file count has been reached.
/QBL Quits before the byte count exceeds the limit (same as /QB).
/QBT Quits when the total byte count reaches the trigger point.
/QSL Quits before the space dips below the limit (same as /QS).
/QST Quits when the remaining space reaches the trigger point.
----- Miscellaneous switches -----
/NI Becomes nice to other tasks by idling (1000 msec) between actions.
/NI<n> Same as /NI. Specifies n msec as the idle time (0 to disable it).
/CF<fname> Specifies a Command File whose contents are treated as if
they were entered at the position it appear in the command line.
The Command File is a text file which may have multple lines.
// Starts a comment field. The rest of the line will be ignored.
:: Starts a comment field. The rest of the line will be ignored.
(See XXTB #37 for a full coverage of this feature.)
/1 DATMAN One-pass copy (when copying from DATMAN tape, default).
/0 Disables DATMAN One-pass copy (not recommended, but allowed).
/V Verifies after copy default (same as /V1).
/V1 Verifies after copy (quick test --- file size match).
/V2 Verifies after copy byte-by-byte check (DATMAN 2-pass).
/V0 Disables verify switch (canceling /V, /V1, or /V2).
/VE Displays only error cases of DATMAN 2-pass verify (/V2).
/ER Emulates XCOPY's exit code (for ERRORLEVEL check in batch files).
/CLONE Duplicates a directory (volume). This switch is a shortcut of
the following combination: /KS/H/E/R/Q/Y/BI/ZY/ZE/oD0.
/CK Checks remaining space before copy (default).
/CK0 Disables the pre-check of remaining space before copy.
----- The following switches control the progress bars -----
/PB Shows Progress bar for the job (default file progress >= 1M).
/PB<n> Shows Progress bar for the job and another Progress bar for a
single-file progress with file length greater than <n>, which is
specified in bytes (or with a suffix, K, M or G) (default: 1M).
/PBH Enables Progress bar Halt/Abort button (default).
/PBH0 Disables Progress bar Halt/Abort button.
----- The following switches control List output -----
/L Same as /LLZ which performs the list operation (no file copy).
/L<items> Customizes the format for List operation (no file copy).
<items> is a string of one or more of the following letters
which selects the combination and the output order.
D file date
T file time
Z file size in bytes
A file attributes: A(rchive),H(idden),S(system),R(eadonly)
S short name (8.3)
L long name with full directory path
Note: When S and L are both missing, L is used by default.
Note: The format specified by /FM<items> will be used if /L
is not followed by its parameter.
/LTREE Lists directory tree (without copy or making directories).
Note: with /LTREE, the /DA/DB/Do parameters apply on dir time.
/F Displays full source and destination file names while copying.
/Fo<fname> Displays full source and file names and also saves into a file.
/FM0 Cancels the /FM<items> parameter previously set.
/FM<items> Specifies the output line format for /L and or /Fo output.
<items> is a string of one or more of the following letters
which selects the combination and the output order.
D file date
T file time
Z file size in bytes
A file attributes: A(rchive),H(idden),S(system),R(eadonly)
S short name (8.3)
L long name with full directory path
Note: When S and L are both missing, L is used by default.
Note: /L/FM<items> can be combined into a /L<items> switch.
----- Miscellaneous switches -----
/MD<dir> Makes directory before other actions (even with /L).
Tip: make a date-encoded directory with a macro reference.
e.g., /MDc:\Bkup/$DATE$ (even good for log files).
----- The following switches control Security Information -----
/SC Same as /SC3 (copies security info).
/SC0 Cancels the /SC or /SF switch (no security info copied).
/SC1 Copies security info (Permissions only) when a file is copied.
/SC2 Copies security info (Auditing only) when a file is copied.
/SC3 Copies security info (both Perm, Audit) when a file is copied.
/SF Same as /SF3 (fixes up security info)
/SF0 Cancels the /SC or /SF switch (equivalent to /SC0).
/SF1 Fixes up security info (Permissions only) (no file copy).
/SF2 Fixes up security info (Auditing only) (no file copy).
/SF3 Fixes up security info (both Perm, Audit) (no file copy).
Note: /SC and /SF work only when src and dst are both NTFS.
----- The following switches control file-write cache -----
/CA Enables all cache. Same as /CA7 (default).
/CA0 Cache control: src-rd = OFF dst-wr = OFF dst-rd = OFF
/CA1 Cache control: src-rd = OFF dst-wr = OFF dst-rd = ON
/CA2 Cache control: src-rd = OFF dst-wr = ON dst-rd = OFF
/CA3 Cache control: src-rd = OFF dst-wr = ON dst-rd = ON
/CA4 Cache control: src-rd = ON dst-wr = OFF dst-rd = OFF
/CA5 Cache control: src-rd = ON dst-wr = OFF dst-rd = ON
/CA6 Cache control: src-rd = ON dst-wr = ON dst-rd = OFF
/CA7 Cache control: src-rd = ON dst-wr = ON dst-rd = ON
/CL Legacy switch, replaced by /CA
----- The following switches control the console output -----
/EC Echoes the entire command line (after macro processing).
/Q0 Displays all file names.
/Q Same as /Q1. Does not display files which are skipped.
/Q1 Does not display files which are skipped.
/Q2 Does not display directories which are excluded.
/Q3 Does not display file and directory names while copying.
/ZS Disables the sign-on message and statistics output.
----- The following switches control the log output -----
/oA<fname> Appends to a logfile, reporting errors. (does not overwrite log).
/oN<fname> Outputs a new logfile, reporting errors (make a new log) file.
/oQ Surrounds pathname output with quotation marks
/o0 Cancels the /oN or /oA switch specified earlier.
The screen and the log file output can be fine tuned by the followng:
/oP<n> Parameter (command switch detailed) list.
/oI<n> Include item (alternate file template) list.
/oX<n> Exclude item list.
/oF<n> File list (files which were successfully operated).
/oS<n> Skipped file list (with the reason why skipped).
/oD<n> Deleted file list (by a /Z or /ZY switch).
/oE<n> Error summary with the system error code
These items can be controlled by the suffix <n> value, 0-3.
0: No output
1: Screen only
2: Log file only
3: Screen and Log file both
Note: It is advised that the log file created by /oA or /oN to be
free from the names of successfully copied files that would
overshadow relatively infrequent lines of error and warning.
Instead, use the /Fo switch to create a separate file for a
list of successfully copied files.
/DEBUG Shows the command parameters and prompts you to start.
/DEBUGX Shows the command parameters and exits.
/HELP Shows the switches in detail (print this output).
/HELP /X Shows Partial Help (switches starting with letter X).
/HELPA Shows the /HELP listing in alphabetical order.
/HELPE Lists the Exit codes (ERRORLEVEL values) returned by XXCOPY.
/? Shows a summary of the switches on one page.
... /? Shows related switches when entered with other switches.
Note: All XXCOPY command switches are case-insensitive.
The alphabet, O, is spelled in lower-case (o) in this page to
help distinguish it from the numeric zero (0).
Note: Virtually all of the switches can be disabled by adding 0 (zero)
at the end (e.g., /A and /A0). Due to the space limitation and
their redundant nature, only some of these cases are listed in
the help text.
----- Pre-defined macros to embed current date and time ----
/$xxxx$ Pre-defined macros for current date and time which may appear
anywhere in the command argument and other XXCOPY parameters.
Examples below are for the current time, Dec 25, 2002 13:15:30
/$DATE$ Expands to month and date (equivalent to /$MMDD$) --> "1225".
/$TIME$ Expands to hour and minutes (equiv. /$HHNN$) --> "1315".
/$YYMMDD$ Expands to 2-digit year month day --> "021225".
/$YYYY-MM$ Expands to 4-digit year month --> "2002-12".
/$YY-M-D$ Expands to 2-digityear-mo-dy (mo and dy without leading zero).
/$HHNNSS$ Expands to hour minutes second --> "131530".
/$MON-DD$ Expands to month day --> "DEC-25".
/$II-IWK-K$ Expands to the ISO 8601 year-week --> "02-W52-3".
/TM0 Cancels the time offset set by /TM+ or /TM-.
/TM+<n> Adds an offset to the current time of macro reference.
/TM-<n> Subtracts an offset to the current time of macro reference.
Note: The offset value <n> for /TM+ and /TM- is specified in days
unless it is appended with a one-letter suffix (D, H, M, or S
which stand for Days, Hours, Minutes, or Seconds respectively).
----- Environment Variables in XXCOPY command files ----
/%xxxx% Environment variable (E-Var) reference in command files
(/CF and /EX). Like the macro reference counterpart,
the string value which correspoinds to an E-Var can be
brought in the command line text using the /%xxxx% syntax.
Note that this syntax should be used only inside the
external file text for XXCOPY (/CF and /EX) which cannot
be processed by the OS's command processor. That is, in
the regular command line, the E-Var reference is already
supported (without a leading slash as the prefix).
----- Installation of XXCOPY ----
/INSTALL Installs the XXCOPY software package on your computer.
/INSTALL:<dir> Installs XXCOPY at user-specified directory.
/UNINSTALL Uninstalls XXCOPY from your computer.
/LICENSE Displays the XXCOPY license status on your computer.
/HOSTS Displays the names of remote hosts accessed by XXCOPY.
----- The following switches are DATMAN specific -----
DATMAN is a revolutionary tape control software also published
by Pixelab, Inc. It makes a tape drive behave almost like a disk.
/J Forces DATMAN catalog (journal) flush.
/J0 Suppresses DATMAN's automatic catalog (journal) flush.
/J1 Flushes DATMAN catalog when needed (default).
/J2 Flushes DATMAN catalog unconditionally at the end.
/G<n> Sets DATMAN N-Group (redundant) write. (<n> : 0 - 7).
e.g., /G1 writes the same data twice on DATMAN tape.
----- Environment variables that affect XXCOPY-----
COPYCMD Specifies file-overwrite prompting.
/Y suppresses the prompt (always overwrite)
/-y prompts you for a Yes/No/All option for a file overwrite
(This feature is for the COPY/XCOPY compatibility.)
XXCOPY Specifies XXCOPY's command argument. This argument string
is evaluated first and therefore the user-typed command line
can override it. The syntax is the same as regular argument.
XXCOPYX Specifies a list of exclusion specifiers (xspec).
Do not use switch prefix (/X). See the /X switch for details.
/ZE Disables the use of all Environment Variables for XXCOPY.
/ZX Disables the use of the Environment Variable XXCOPYX.
/ZX0 Enables the XXCOPYX settings. Good for /CLONE and /RMDIR.
The shortcut /CLONE and /RMDIR contain /ZE as a component.
e.g., /CLONE/ZX0 allows the use of XXCOPYX settings.
Summary XXCOPY switches that check two directories: -------
/ src \
Files are classified into four groups; | ---+---
--------------------------------------------- | A / B | \
A files in src which do not exist in dst | | | |
B files in src which also exist in dst \ | C / D |
C files in dst which also exist in src ---+--- |
D files in dst which do not exist in src \ dst /
-------
/BB all files in A (none in B)
/BI all files in A plus files in B that are different in filetime or size
/BX all files in A plus files in B that are different in filetime
/BZX all files in A plus files in B that are different in size
/BZL all files in A plus files in B that are larger
/BZS all files in A plus files in B that are smaller
/BZE all files in A plus files in B that are the same size
/BN all files in A plus files in B that have newer filetime
/Bo all files in A plus files in B that have older filetime
/BE all files in A plus files in B that have exactly the same time and size
/BS (none in A) files in B that have exactly the same time and size
/U (none in A) all files in B (subject to other switches)
/U/BI (none in A) files in B that are different in filetime or size
Note: all the variations in the backup switches (/Bx) include the files in A
with the exception of /BS to be consistent with the spirit of BACKUP.
As shown in the example (/U/BI), adding /U eliminates the files in A.
/RS files in A and/or B that satisfy other specified switches (for remove).
/RC same as /RS (for remove-after-copy).
/RD (none in D) files in C that would be overwritten (for remove).
/RX all files in D (for remove).
Note: /BS for copy usually accomplishes nothing but is useful as /RS/BS.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Source Specifier:
XXCOPY's first argument (without regard to command switches) is
the source specifier. The source specifier is usually a path
specifier for the source. But, for XXCOPY (as well as for XCOPY),
the source specifier may contain the "Base" directory and an
optional file pattern specification whose subtleties are not fully
appreciated by many XXCOPY users.
The source specifier has three parts:
[ volume_spec ] [ base_dir ] [ pattern ]
Example (the destination specifier is omitted here):
xxcopy c:\mydir\*.doc
xxcopy "c:\program files\mydir\myfile.doc"
xxcopy \\myserver\drivec\config.sys
Here, the three parts in the source specifiers are quite obvious. In
the second example, the double-quotes (") make XXCOPY to treat the
entire command argument as one source specifier. Without the double-
quotes, the embedded space character would make it two parameters
volume_spec
In most cases, the volume spec is a drive letter followed by a
colon (e.g., C: ). But, it can be a universal naming convention
(UNC) string for a volume in a network (e.g., \\myserver\drivec ).
If you omit volume_spec, the current drive is assumed.
base_dir
The name of the source directory. When the XXCOPY command
contains the subdirectory switch (/S and/or /E), the base_dir
specifier denotes the starting directory where the source
files and subdirectories are located. The base_dir part
must not contain wild card characters.
pattern
The last part within the source specifier denotes the pattern
matching string which may contain wildcard characters (* or ?).
It matches only the last components within a full filename.
You may omit any of the three parts, but you may need something
as the source specifier as the space holder so that you can specify
the destination specifier as the second non-switch argument. In
this case, you may use "." which denotes the current directory
as the source.
When you omit either the base_dir part or the pattern part,
that is, when a source specifier without a backslash separating the
two parts, the exact meaning of the command become ambiguous.
We will discuss the source specifier ambiguity in a later
article.
Destination Specifier:
The destination specifier has two parts:
[ volume_spec ] [ dest_dir ]
volume_spec
As for the source specifier case, the destination may contain
a volume specifier (e.g., C: ). If it is omitted, the volume
of the current directory will be used.
dest_dir
The name of the destination directory. Here, the destination
must be a directory name (which may or may not yet exist
in the destination volume). Unlike the original COPY command,
you are not allowed to specify wildcard characters in the
destination specifier which would be conveniently used to
perform renaming action while copying the files.
XXCOPY does not rename files while they are copied. therefore,
no wildcard characters have no place in dest_dir.
Unlike the source specifier counterpart, the destination specifier
consists of only two parts both of which are optional. When you
omit both of them, then the command line would have no explicit
argument as the destination specifier. Don't worry, the current
directory will be used as the default destination directory. Or,
you may just type "." which denotes the current directory explicitly.
Prefix and Delimiters:
Earlier versions of XXCOPY switch used to accept either a slash (/)
or a hyphen (-) followed by at least one letter or digit. That was
started with the DOS version (XXCOPY16.EXE) which did not have to
resolve the hyphen character from filename before the long name
was introduced. However, due to the fact that the hyphen is now
a legal character in Win32's long filename, this practice had to
be abandoned. It became clear lately that the over all price to
pay in the twisted syntax rules to support of the Unix-like switch
prefix has become too high for the now-questionable "benefit".
Usually, command line parameters are separated by blanks. However,
you may safely combine switches without separating blanks for the
command switches (e.g., /s/t/u/v). However, you must separate
the source and the destination specifiers by blanks.
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #02
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: What are the differences between XCOPY and XXCOPY?
Date: 2000-11-30 (revised)
====================================================================
Introduction:
When we designed XXCOPY, one of the key design principles was to
keep the command syntax and the behavior of XXCOPY as close to
those of the original XCOPY program. Although we did not agree
with all the idiosyncrasies of XCOPY, modifying anything XCOPY
already implements would cause substantial confusion to the users.
If we change things arbitrarily, any incremental improvements we
may add would be more than offset by the burden of remembering
the specifics of changes we make. That would not benefit anyone.
Therefore, the changes we added to XXCOPY on purpose are kept to
the absolute minimum. The changes we made are those with
substantial benefits to the users.
The key arguments, source and destination:
Like XCOPY's predecessor, the built-in COPY command of COMMAND.COM,
XXCOPY has two basic arguments without counting any other switches.
XXCOPY source [ destination ]
Here, the semantics of the first argument (source) are almost the
same as the first argument of the traditional XCOPY command. It
is the source file/directory specifier, which is a combination of
the source directory and optional filename pattern specifier.
To be precise, this combination of directory specification with
the filename pattern connected by a backslash does not conform
to a regular so-called pathname specifications. (We will discuss
the exact definition of the source specifier in another Technical
Bulletin article in full detail.) Just remember that the source
specifier is pretty much the same as that of XCOPY.
The destination specifier is optional as in the case of the
original XCOPY and COPY commands. When the destination is not
specified, XXCOPY uses the current directory as the destination
direction.
Destination specifier (Difference #1):
In XXCOPY, the destination specifier (when supplied by the user)
refers to the name of a directory whether it exists or to be
created by the command. In any event, the destination never
specifies any particular filename. It always specifies the name
of the destination DIRECTORY.
The reason for this change was the confusing and bothersome
behavior of XCOPY. For one thing, when you specify a non-exist
directory as the destination of XCOPY, you would be greeted by
the familiar prompt:
Does XXXX specify a filename
or directory name on the target
(F = file, D = directory)?
In nearly all cases, you would type D and sigh a long DUHHHHHHH!!!!
Yet, because XCOPY allows the action to include renaming the file
while it is being copied, this ambiguity arises. It is simply
carrying on the legacy of the COPY command. While the copy command's
simplistic "rename-while-you-copy" features using a wildcard
specifier works, we consider the action quite dangerous.
When you use a wildcard with "rename-while-copy" feature which
involves a large number of files, you may accidentally create a
filename collision, which would abort the "rename-while-copy" action
in the middle. The result would be a big mess of partially
renamed files.
We consider the "rename-while-copy" a source of much trouble and
therefore, we discourage your using it. After all, XXCOPY is not
designed to handle one or two files. You can always use the simple
COPY command to do just that. Therefore, in our opinion, eliminating
the double meaning of the destination specifier from XXCOPY's second
argument, we can avoid the side-effects of the "rename-while-copy"
operation altogether and also eliminate the bothersome prompt of
"Do you mean F = File, or D = Directory". Also, we are sure that
everybody has experienced the huge file which is accidentally
created by a simple COPY command with a directory as the source
and a non-existent directory as the destination. The copy command
interprets the destination as a filename rather than a directory and
accumulates all the source files combined into a huge pile of useless
bytes.) Anyway, we had enough confusion with the double meaning
of the destination specifier. XXCOPY dares to correct this problem.
With XXCOPY, the destination is always a directory, never a file.
XXCOPY.EXE and XXCOPY16.EXE (Difference #2):
In the case of XCOPY, it automatically switches between XCOPY.EXE
(a 16-bit program) and XCOPY32.EXE depending on the environment.
In fact it is quite convenient for most users to forget about
the distinction between XCOPY and XCOPY32. Some users may not
even know the existence of XCOPY32.EXE. The actual mechanism is
that when you run XCOPY.EXE in the Win32 environment, XCOPY.EXE
automatically detects the current environment and will execute
XCOPY32.EXE instead. We also consider this feature quite dangerous.
That is because the behaviors of XCOPY and XCOPY32 are not identical.
For example, the treatments of a pathspec with wildcard characters
in the DOS and Win32 environments are significantly different.
Therefore, any large-scale batch file invocation should distinguish
the usage of XCOPY and XCOPY32 to be safe.
Due to that consideration, we feel the danger of having unintended
COPY operations performed in the different machine environments
outweighs the convenience of the automatic invocation of the 32-bit
version. Therefore, XXCOPY (which is the 32-bit version) will NOT
automatically invoke the 16-bit counterpart. You must select the
appropriate version when you need the distinction. Since the
16-bit version, XXCOPY16.EXE, is seldom used, we chose the scheme
where the shorter name is for the 32-bit version. Also, in a
32-bit environment, XXCOPY does not have the overhead of XCOPY,
which always loads and runs XCOPY.EXE before XCOPY32.EXE,
unless you specify XXCOPY32 in the first place.
XXCOPY is always in 32-bit and XXCOPY16 is always in 16-bit.
The /C switch as the default (Difference #3):
XCOPY32 added the much needed switch, "/C" which allows an
automatic continuation of the copy operations after encountering
an error condition. The C stands for "Continue on error".
Before Microsoft introduced Windows 95, and therefore, the new
XCOPY32.EXE utility, DATMAN-DOS users demanded a solution to
the "share-violation" problem in a backup job of NetWare server.
Even within a modest sized network, there are always a few files
which are open at the time of a server backup job. When XCOPY
tries to open a file which is already opened by another process,
the access results in the error condition where the user had
only three choices: Abort, Retry, or Fail.
None of these choices would let XCOPY continue the operation.
As a matter of fact, XXCOPY's predecessor (DCOPY.EXE) was born
to correct this problem even in the DOS-only days. The first
enhancement to the XCOPY command was the /C switch. Now, with
XCOPY32, which supplies the much-needed switch, the problem was
pretty much behind us.
We had XXCOPY's /C switch work exactly the way XCOPY32's /C
switch works. When it was specified, an error condition that
would have aborted the entire copy operations will continue
until all the qualified files are copied. Alas, the most
frequent technical support issue with the earlier versions
of XXCOPY was due to the omission of the /C switch. After
answering many tech support Emails, we have reached the
conclusion that Microsoft should have made the /C switch its
default mode with a provision to disable it.
For this reason, we broke our rule of adhering to XCOPY32's
behavior exactly, for better or worse. Here, we made XXCOPY's
implementation of the /C switch the exact opposite of how XCOPY32
handles the case. We believe it is in the best interest of the
users. As of this writing, Microsoft's 16-bit counterpart,
XCOPY does not have the /C switch.
With XXCOPY (also with XXCOPY16), the /C switch is automatically
invoked by default. You need to specify /C0 to disable this
feature and to allow XXCOPY to terminate at the first instance
of an error condition.
The /T switch always enables /E (Difference #4):
Since the /T switch is to construct the directory tree (without
the files), it makes no sense to run it without /S or /E (which
handles subdirectories). We consider the /T/S combination
quite useless and hence chose to always include the E switch
implicitly. We believe the /T switch is now trouble free.
The use of quotatoin marks in a command line (Difference #5):
When a pathname contains an embedded space, the whole string
must be surrounded by a pair of quotation marks (").
Microsoft's XCOPY allows a very liberal usage of quotation
marks to an extent it even accepts bizarre strings. For
example, XCOPY allows the following strings without problem:
"c:\Program Files\My Directory\Myfile.doc" // OK
"c:\Progra""m Files\My Directory\Myfile.doc" // two pairs
c:\Program" Files\My "Directory\myfile.doc // bizarre
We feel XXCOPY should not allow such questionable constructs
even though they are accepted by XCOPY. While it is not
impossible for us to make XXCOPY imitate the behavior closely,
we would have hard time defining and explaining the exact
syntactic rules. So, we chose to deviate from XCOPY's rules.
XXCOPY's rule for the quotation mark is very simple:
The quotation marks must be at the both ends of a pathname.
Other differences:
In almost all other cases, the differences between Microsoft's
XCOPY and our XXCOPY are a result of enhancements rather than
alteration of the XCOPY behavior which already existed.
With the few notable exceptions discussed in this article, the
differences between XCOPY and XXCOPY are remarkably small.
For example, XXCOPY pays attention to the short name alias
which preserves the short name after the copy (TB#02). But,
this is a pure "improvement" rather than "change" which does
not require user attention or precaution.
Therefore, you need not worry much about how to use XXCOPY
if you already know XCOPY. You can pick just a few new
features when you want to learn XXCOPY. Over time, you may
come to like XXCOPY and exploit its unique features to write
your own very powerful batch script for a backup operation.
XXCOPY's major enhancements:
0. Wild-src Wild-Wild-Source, multi-level, multi-wildcard source
1. /X exclusion specifier and related switches (/EX)
2. /IN inclusion specifier for alternate file pattern template
3. /Bx variations in backup related switches
4. /NX retains the short name exactly
5. /NS /NL renaming short name and long name based on the other
6. /D date matching with many variations
7. /Rx /Z removes files using the versatile file selection schemes
8. /SG/SX gathering files or flattening a directory tree
9. /SZ: select file by the file size (range)
10. /CC /CCY cyclic copy cases handled with the exclusion method.
If you have a suggestion for a new XXCOPY feature, tell us about
it. We will consider any user feedback very seriously.
Please send E-Mail to <tech@xxcopy.com> for comments, suggestions,
questions, etc.
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #03
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: Problems in filename aliases (8.3 names) in Win32
Date: 1999-11-27
====================================================================
Background:
When Microsoft implemented the long filename in Windows 95,
it came up with a scheme which assigns an alias (or short name in
the so-called 8.3 format) for every long name. Typically, a short
name starts with the first 6 letters in the long name followed by
a tilde and a digit, (numeric tail like XXXXXX~1.XXX), discarding
remaining characters except the three-letter extension. The short
name is synthesized by the file system driver for the volume, in
such a way that all filenames become unique one another within
a given directory. The rule to assign the numeric tail is very
simple; it picks the smallest decimal value not yet claimed in the
directory.
As long as the aliases are used by legacy programs to access files,
the actual filename assigned to a file should not be very important.
But the truth is that even Windows 95 itself accesses certain files
using their short name aliases. One notable situation is when the
most primitive virtual drivers (VxD) are loaded at the beginning
of Windows 95 system start up sequence. Since the long name support
is provided by a module called IFSMgr (InstallableFileSystem Manager)
which is itself a VxD module, locating and accessing the VxD files
are all performed strictly using the short name alias. If you
examine various parts of the system registry, you will find many
8.3 name strings. In short, the system relies on the 8.3 naming
scheme in a very crucial manner.
The problem:
The problem arises when a directory contains a number of files
whose aliases share a common base part (differing only by the numeric
tails). When you copy these files to another directory, the
aliases will be assigned by the simple (first-come-first-served)
algorithm, the first such file copied to the destination directory
will have numeric tail of ~1 regardless of what was its alias
in the source directory. Therefore, the Windows operating system
does *NOT* preserve the alias after copying. We consider this a
very serious defect in the file system design. Most file copy
programs ignore this aspect in file copying. This includes
Explorer (drag-and-drop), COPY, and XCOPY.
Example:
Here, we make a simple sequence in a DOS Box to illustrate the point.
It is assumed that you have the \autoexec.bat file handy (can be any
file). Let us create a pair of files with names that would have the
same short name base for the alias.
C:\> mkdir \src
C:\> copy \autoexec.bat \src\LongNameA.bat
C:\> copy \autoexec.bat \src\LongNameB.bat
C:\> dir \src
LONGNA~1.BAT 1234 11-21-99 11:27p LongNameA.bat
LONGNA~2.BAT 1234 11-21-99 11:27p LongNameB.bat
Use the traditional method to copy the files. When you use another
method like Drag-and-Drop, you would get the same result. First,
pick the file whose short name numeric tail does not end with ~1.
C:\> mkdir \dst
C:\> copy \src\LongNameB.bat \dst
C:\> copy \src\LongNameA.bat \dst
C:\> dir \dst
LONGNA~1.BAT 1234 11-21-99 11:27p LongNameB.bat
LONGNA~2.BAT 1234 11-21-99 11:27p LongNameA.bat
Here, the first file created in the destination received the numeric
tail of ~1, even though its alias in the source was not that.
If you don't see the difference in the left hand side (the aliases),
see the long names to your right (---B and ---A are opposite).
Enter XXCOPY:
Now, try the same operation using XXCOPY in the \new directory.
C:\> mkdir \new
C:\> xxcopy \src\LongnameB.bat \new
C:\> xxcopy \src\LongnameA.bat \new
C:\> dir \new
LONGNA~2.BAT 1234 11-21-99 11:27p LongNameB.bat
LONGNA~1.BAT 1234 11-21-99 11:27p LongNameA.bat
Here, the files in the \src directory and in the \new directory
match exactly (both the long names and the aliases) albeit the
new order reflects the order of copying.
Other cases:
The above example is just one of the many problems with aliases.
For example, when you delete the file with the numeric tail of
---~1 in the source directory and copy the files; the first
files copied to the destination will be assigned with an alias
ending with ---~1. In essence, the short name alias is
systematically synthesized by Windows kernel without regard to
what the original alias in the source directory was. This kind
of discrepancies in file and directory names lead to subtle but
serious problems which are often very difficult to even diagnose.
How safe is XXCOPY?
XXCOPY performs the alias name change using only published
standard Win32 file I/O API. XXCOPY does not attempt to
manipulate the raw directory data structure of the file system.
Nor does XXCOPY perform any unorthodox techniques to implement
the alias matching feature. The operation utilizes a combination
of simple file-renaming system calls. Therefore, it is completely
safe.
On the other hand, when the destination directory already has
a file with the needed alias (i.e., a case of alias name
collision), XXCOPY does not perform such an operation which
would otherwise create an invalid directory data. Of course,
the same name for more than one file is No No in a file system.
Since XXCOPY supports remote machines over a network, the alias
(8.3 name) support function also works across network.
Win95/98 and WinNT/2000/XP:
If your use a dual-boot system (Win95/98 and WinNT/2000/XP), there
is one more pitfall which is related to the shortname.
Please read our new article, XXTB #08.
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #04
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: What is and what is not included for copy
Date: 2001-01-18
====================================================================
[ Note: this article is about XXCOPY's file selection mechanism
in general, not about the recently added /IN switch that
"includes" alternate filename pattern ]
The problem of being "Too Powerful"...
With the huge set of command switches offered by XXCOPY, even
a serious user starts to wonder if a particular file is included
in the XXCOPY operation or not. Indeed, there are a number of
switches which sound very similar and become quite confusing
which of the switches has "precedence" over the other. Yet,
there is hardly any mention of precedence in the XXCOPY help
and documentation. This article will give you a simple rule
which resolves all such questions and gives you the confidence you
need when you use XXCOPY in your day-to-day computing.
Combining switches:
Some XXCOPY switches suggest an inclusion of files with certain
characteristics. For example,
XXCOPY C:\mydir\ D:\newdir\ /H
It is understood by many XXCOPY users that with the /H switch,
hidden and system files (which would normally be excluded) will
be "included" in the copy operation. Let us add another switch.
XXCOPY C:\mydir\ D:\newdir\ /H /U
The /U switch is used to "update" existing files in the destination
directory. In this case (/H/U), hidden files will be included in the
operation by the /H switch, but the files which are not already
present in the destination will be excluded by the /U switch. Then,
what about the files which are hidden (to be included) but are
not present in destination (to be excluded)? The question seems to
be whether /H or /U has the precedence. Let's add some more.
XXCOPY C:\mydir\ D:\newdir\ /H /U /BI
/BI stands for "Incremental Backup" meaning that it will select
files which are different (by comparing the file date and file
size between the files of the same name in the source and the
destination). The /BI switch includes those files which exists
in the source but not in the destination. But, if you combine the
three, /H/U/BI, then the /U switch (which excludes new files to the
destination) and the /BI switch (which includes new files) seem to
contradict each other while the effect of /H seems fine.
Does the order of these switch makes the difference? The answer is
No. At least that is not the case because /U and /BI are not in a
mutually exclusive set of switches. But, clearly, these two switches
seems to have opposing effects on the files which do not exist in the
destination directory. What is the precedence? What is going on?
The golden rule:
XXCOPY's switches are all exclusionary.
Well, it has some element of over-simplification, but it is the
shortest rule that you can remember. Each XXCOPY switch excludes
certain group of files by some measure. By adding another switch,
some more files are excluded. Obviously, there are many
switches in XXCOPY which do not participate in the file selection
process. For example, the /W switch is to let XXCOPY wait for a
keyboard input before the copy action really begins. It has
nothing to do with qualifying files for inclusion or exclusion.
But, for all the command switches which determine whether a
file is to be copied or not, the above golden rule applies.
The exclusion process:
If you consider that all of XXCOPY file-selection switches are
exclusionary parameters, everything will start making sense.
And you will realize that the precedence of switches becomes a moot
point. You may need to view some of the switches from a different
angle. Here, we need some rephrasing of the nature of the switches.
XXCOPY C:\mydir\ D:\newdir\ /H
Earlier, we said /H was to include hidden/system files. Now, let
us rephrase it by saying "/H does not exclude hidden/system files".
Yes, it is still awkward. But, remember this is a case where the
default switch in the same category (/H0) did the exclusion and
you are simply negating it. Let us revisit the implied case;
XXCOPY C:\mydir\ D:\newdir\
XXCOPY C:\mydir\ D:\newdir\ /H0
These two lines produce exactly the same result. Since it is a
default, most XXCOPY users do not add such a switch. These lines
should read that "the /H0 switch excludes hidden/system files from
the copy operation".
Once more,
XXCOPY C:\mydir\ D:\newdir\ /H
We now know that the /H switch simply negates the default exclusion.
The wording, "/H does not exclude hidden/system files" sounds OK, now.
XXCOPY C:\mydir\ D:\newdir\ /H /U
Adding the /U switch, it becomes "/H does not exclude hidden/system
files" but "/U excludes files that are not present in the destination
directory". Here, the exclusion rule of /U goes by the face value.
XXCOPY C:\mydir\ D:\newdir\ /H /U /BI
Again, we have the /BI (incremental backup) switch which reads as
"/BI excludes files that exist in destination with identical time
and size". This does not contradict with the /U switch which
"excludes files that are not present in the destination". All of
the excluded files will be excluded. That's simple.
Exclusion by the name:
Of course, by far, the most obvious parameter to be used in the
exclusion process is by the directory and filename. Because it
gives us a very wide range of opportunities to exploit in
expressing what to exclude, we did put a lot of thoughts in the
design of this (probably the single most significant enhancement)
feature. Therefore, the /X switch deserves its own treatment
in a separate article, XXTB #05.
It is indeed a very natural way of excluding a group of files.
Now, to come to think of it, we wonder why we have not seen
similar features in most other file copy utilities...
Conclusion:
In essence, each command switch has its own way of specifying the
files to exclude. Each and every switch adds more exclusions.
Determining whether a file is excluded from the copy operation is
now easy. Once a file is excluded by a switch, it is out and gone.
Therefore, the more switches you add, the more files you are going
to exclude from the copy operation.
As we add more and more switches, it has become increasingly
difficult for even experienced users to remember all the switches
(it's now over 120 variations and still growing). So, we added
a new feature called "Smart-Help". Just add "/?" at the end
(or anywhere) in your XXCOPY command line. It will select only
the switches you specified in the line, their related switches and
its opposing and mutually-exclusive switches as a group. We find
this new feature quite convenient. You should definitely try it.
Example: XXCOPY c:\mydir d:\yourdir /I /BI /FT /?
To further assist the user in constructing the right combination
of the command switches, XXCOPY now a set of useful switches
which list pertinent command parameters.
/OP outputs parameter list (in exclusionary wording)
/OX outputs exclusion list (after optimization)
/DEBUG displays source and destination and prompts before continue
/DEBUGX displays source and destination and terminates
/W waits for user keyboard input after /OP and /OX switch
Many users find the output text generated by the /OP switch more
understandable than any other documentation of XXCOPY. So, if you
have any doubt on the effect of switches, just add "/OP | MORE"
at the end of the command line. So, to review the whole thing,
a good alternative to the "/?" trick is "/OP/W".
Example: XXCOPY c:\mydir d:\yourdir /I /BI /FT /OP /W
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #05
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: The Exclusion specifier in XXCOPY
Date: 2007-01-28 (revised)
====================================================================
Much of the mostly hidden power of XXCOPY lies in the exclusion
mechanism. We identified the /X switch to be one of the most
important enhancements we made in XXCOPY. Because it is a
complex scheme with many implied rules, one cannot effectively
use the full potential of the exclusion feature without a detailed
explanation of the full scope of the syntax as well as the way
the exclusion scheme is implemented. This article will discuss
all the rules applied to the exclusion feature.
XXCOPY Exclusion switch syntax
/X<xspec> excludes the file or directory item given by
<xspec> which is an exclusion specifier.
If the specifier contains an embedded space,
the specifier must be surrounded by a pair
of double-quotes (").
/EX<xfile> specifies a text file whose name is <xfile>
which contains a list of <xspec> separated by space.
(See XXTB #37 for syntactic rules of the file format.)
/ZX ignores the environment variable, "XXCOPYX".
XXCOPYX The environment variable XXCOPYX specifies a
(env var) list of <xspec> which are separated by a space.
XXCOPY The environment variable XXCOPY specifies a
(env var) list of XXCOPY switches which may be /X<xspec>.
Note that the difference between the two environment variables,
XXCOPY and XXCOPYX is that every item in the XXCOPY value
must be prefixed with a slash (/) followed by an XXCOPY switch
(which can be for any XXCOPY switch) whereas XXCOPYX values are
strictly for the /X switch as a list of exclusion specifiers in
order to save space.
You may specify as many exclusion specifiers as you like.
Some examples of the /X switches
/Xc:\mydir\myfile.txt // specifies just a single file
/X*.tmp // all files that end with ".tmp"
/Xabc* // all files that start with "abc"
/Xmydir\ // the entire directory, "mydir" in the source
/Xmydir\*\* // same as /Xmydir\ which is a shortcut
/Xmydir\*\*.tmp // inside mydir, all files matching "*.tmp"
/Xmy*xyz\*\abc*.c // in directories that match my*xyz, all "abc*.c"
/X*\cache\ // multiple-level subdirectories
/X*\cache\*\* // same as above with a trailing backslash
/X*\cach?\*\* // multiple-level subdir spec may have wildcards
Here, you may see the glimpse of the powerful syntax in the exclusion
specifier. The first example seems the most straight forward. The
fourth example which ends with a backslash is a shorthand of for the
common case of excluding a directory (it abbreviates "*\*" which follows).
Therefore, all of the above examples except the first one contain
or imply at least one wildcard specifier. The last example includes
one asterisks in each of the three parts.
Don't worry about the complexity yet. At least the first example shows
a case which you can use it immediately without any further reading.
Yes, if you have energy to list all of the files you want to exclude,
you may painstakingly list all of such files by giving the full
file specification of each file. Since you will soon run out of the
command line space, you will probably want to set up a text file using
the /EX switch.
E.g., /EXmyexcl.lst
and myexcl.lst contains the following specifiers:
:: this is a comment line
c:\win386.swp :: comment may start like this
c:\autoexec.bat myfile.tmp :: one line may have multiple items
"c:\program files" :: use quotes (") for embedded space
mydir\myfile.txt :: pathspec relative to the source dir
yourdir\ :: entire yourdir\*\*
Syntax rule for the Exclusion List File.
An "Exclusion List File" specified in the /EX switch is a plain
text file which contains a list of exclusion specifiers.
You may list as many exclusion specifiers in one line.
Exclusion specifiers are separated by one or more blank, tab,
and/or newline character. An exclusion specifier cannot be
broken into two or more lines. When a space character is
embedded, the exclusion specifier must be surrounded by a
pair of double-quotes ("). A line may contain a comment field
which will be ignored by XXCOPY. A comment field starts with
two consecutive colons (::) and ends at the end of the line.
We suggest the use of a line for each exclusion specifier which
is followed by a comment.
Definition of the exclusion specifier.
Up to now, the exact meaning of the exclusion specifier has not
been defined. Now, we are going to analyze the syntax and its
meaning to its death. (Note: the exclusion specifier has been
revised on 2000-10-09 with the addition of the multiple-level
subdirectory exclusion feature).
The exclusion specifier has up to three parts.
[ dir_spec\ ] [ *\ ] [ template ]
Although any of the three parts can be omitted, you must not skip
both dir_spec and template at the same time. Note that the last
part (template) can be either a file-template or a directory-
template which will be explained below with more details.
Directory specifier ( dir_spec )
The dir_spec part specifies the base directory of the exclusion.
It is always followed by a backslash (\) character.
The directory can be specified in an absolute path (starting with
the root directory), or a relative path (without a leading
backslash) which is treated as relative to the source directory
(not the "current" directory).
The dir_spec may contain a wildcard specification in its
last part. For example
/Xc:\mydir\level1\abc*\*\template
/Xc:\mydir\level1\a*bc*.?oc\*\template
In both of the examples here, the last part of the directory
specifier (after \level1\) has asterisk(s) in it. The second
example goes one step farther by allowing multiple asterisks
and even a question mark which is another wildcard for a single
letter.
The middle part (*\)
It denotes that the exclusion specification will be applied
not only to the dir_spec directory, but also to all of the
subdirectories underneath. It is equivalent of the familiar
/S switch which is applied to modify the source specifier
meaning that the XXCOPY action will include all subdirectories.
Since we do not have the luxury of a separate /S switch on each
exclusion items, we invented this notation which figuratively
suggests the fact that the directory starts with dir_spec,
ends with the template and anything in between is accepted.
The following two examples highlight the effect of the middle part.
/Xmydir\myfile.* // myfile in mydir\ only
/Xmydir\*\myfile.*c // myfile in every directories under mydir\
Template specifier ( template )
The last part of the exclusion specifier is the template which
may be either a file-template or a directory-template. So, the
exclusion specifier can be more precisely described by using the
following two notations:
[ dir_spec\ ] [ *\ ] [ filetemplate ]
[ dir_spec\ ] [ *\ ] [ dirtemplate ]
Here, the syntactic distinction of the two types is made by
the ending of the template string.
The scope of the exclusion specifier:
The exclusion operation applies strictly on the objects
(files and directories) in the source directory, *NOT*
in the destination directory. If an exclusion item that is
not in the source directory, it will be discarded (not
treated as an error).
Common shortcut notations of the exclusion specifier.
File template
When a lone template is specified without a trailing backslash,
(e.g., /Xmyfile.txt ), it is treated as a shortcut for a
multiple-level filename template which is equivalent to
/X*\myfile.txt). This is mostly for historic reason,
(also, the frequency of this type of usage justifies it).
If you need to specify a one-level filename template, you
should place the dot directory (denoting the current directory)
to distinguish it from the multiple-level case ( /X.\myfile.txt ).
Examples:
/Xtemplate // file which matches the template inside
// the current (src) directory (Multil-Level).
/X*\template // the template applies to all subdirectories
// this is same as above (Multi-Level)
/X.\template // the dot denotes relative to the base (src)
// directory (1-Level)
Directory template
The directory template may have the following four variations
in the ending.
dirtemplate\ // full directory
dirtemplate\*\* // full directory (same as above)
dirtemplate\* // files in the directory (one-level)
dirtemplate\?\* // all subdirectories but not
// the first-level files
The first two notations are interchangeable and denote
the whole directory. And the third and fourth cases are
partial directory notations (when the two are combined,
it will match the whole directory.
Examples:
/Xdirtmpl\*\* // excludes all matching directories in the
// base (src) directory and its contents
/Xdirtmpl\ // same as above (the triling backslash
// denotes everything inside the directory)
/X.\dirtmpl\ // in the case of the directory template,
// it applies to one directory relative to
// the base (src) directory (1-Level)
/x*\dirtmp\ // you may make a directory template apply
// to many instances (Multi-Level)
/xc:\windows\* // specifies all the files in the first
// level of the c:\Windows directory such
// as, EXPLORER.EXE, WIN.INI, COMMAND.COM
/xc:\windows\?\* // this does not includes the first level
// files but all subdirectories in it such
// as \WINDOWS\SYSTEM\ \WINDOWS\DESKTOP\ etc.
Since both dir_spec and dirtemplate may contain wildcards,
it could be as complex as...
/Xc:\mydir\pat*ern\*\dir???\*\*
This one excludes all subdirectories which starts by "dir"
followed by three characters which appear in any level of
subdirectory under any directory inside c:\bydir whose
name match "pat*ern".
Note that the following two are distinct:
/Xdir_spec\* // one layer only (subdirectories not excluded)
/Xdir_spec\*\* // the entire dir_spec directory is excluded
XXCOPY allows you to exclude either the entire subdirectory
(which affects both files and directories of any level), or
one directory layer (which affects only files in the immediate
level but not subdirectories).
The variations in exclusion specifiers (11 cases)
The exclusion specifier may be classified into the following
eleven classes (A - K).
simple cases 1-Level templates Multi-Level templates
-------------------------------------------------------------------
D dir_spec\filetmpl H dir_spec\*\filetmpl
A dir_spec\* E dir_spec\dir_tmpl\* I dir_spec\*\dir_tmpl\*
B dir_spec\?\* F dir_spec\dir_tmpl\?\* J dir_spec\*\dir_tmpl\?\*
C dir_spec\*\* G dir_spec\dir_tmpl\*\* K dir_spec\*\dir_tmpl\*\*
Note that a dir_spec may be specified with wildcard characters
in the last component level. For example,
c:\mydir\Level2\last?level\* // simple case
c:\mydir\Level2\last?level\template\ // 1-level case
c:\mydir\Level2\last?level\*\template\ // multi-level
Also, the file_template or directory_template may contain
wildcard characters.
c:\mydir\L2\last?level\file?template // simple filepattern
c:\mydir\L2\last?level\dir?template\ // whole directory
c:\mydir\L2\last?level\*\dir?template\* // 1-level files
c:\mydir\L2\last?level\*\dir?template\?\* // Multi-level case
Here, to illustrate the wildcard in the respective compoents,
a questionmark(?) was added where a wildcard is permitted
(last?level\, file?template or dir?template).
Note that whereas the dir_spec shown above may consists of many
levels of directories, the template specifiers (dir_tmpl) in
Groups I, J and, K must be a single-level directory template
(without a backslash inside).
The optimization of exclusion matching.
In a very large scale backup operation, an XXCOPY job may encompass
an entire volume as the source directory (such as c:\*). To make
the matters worse, the more files the source directory contains,
the more the need for the exclusion specifiers grows. Therefore,
it is entirely possible that the entire C: drive may contain
70,000 files and the total number of exclusion items the user specify
in the exclusion list file with the /EX switch may contain literally
hundreds of various exclusion specifiers. If we were to test every
file against this very large number of exclusion list, the combination
will easily reach tens of millions which would slow down the entire
backup process. Therefore, XXCOPY performs preprocessing steps
to analyze the set of exclusion specifiers. First by classifying
them into the five classes, some redundant exclusion specifiers can
be removed. For example, if a dir_spec is specified in Class B,
any subdirectories of the same directory in Classes C, D, E, or F
regardless of the template will be automatically excluded because
the same directory in Class B spec overshadow any subset of the
directory. Moreover, in the actual XXCOPY implementation, the
the active file pattern matching templates is computed to each
subdirectory to reduce the number of filename matching to
eliminate a significant number of redundant combinations.
Debug feature
Because of the complexities of the exclusion parameters when the
number of exclusion specifiers become substantially large, you may
analyze the list of exclusion parameters immediately after the
initial exclusion parameter optimization steps are completed by the
following two debug switches:
/DEBUG // displays the parameters and prompt for continuation
/DEBUGX // displays the parameters and exit XXCOPY.
/OX // outputs the exclusion parameters in the log file
/OP // outputs the regular parameters in the log file.
/OX/W // a convenient switch to test the exclusion settings
Automatically excluded files.
Since the few output files (e.g., the error log files) which are
generated by the XXCOPY program itself could not be successfully
included in the current copying job if any of them happens to be
in the source directory (or its subdirectories), those files will
be always excluded implicitly.
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #06
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: File Attributes: what are they and how to use them.
Date: 2000-01-17
====================================================================
Since XXCOPY has features which interact with the file attributes,
a discussion of XXCOPY cannot be complete without touching the basics
of the file attributes. This article presents the fundamentals of
the file attributes and how XXCOPY manipulates them. In addition,
some common techniques with the file attributes are discussed.
What are the file attributes?
The operating systems (DOS, Win95/98, WinNT/2000/XP) maintain certain
properties associated with every file and directories in addition to
the file contents (data inside the file). Such properties include
file size in bytes
file date/time (creation time, last-modify time, last-access time)
file attributes
archive bit (shows that the file has not been archived yet)
read-only bit (write-protect the file)
directory bit (distinguishes a directory from a file)
hidden bit (hides from an ordinary directory listing)
system bit (denotes a system file whatever that means)
These properties are mostly maintained by various components of
the operating system and they are handled automatically. So,
the users may not be concerned with them. However, manipulating
some of the properties are not very difficult and it can even be
quite useful at times. This article shows some common techniques
associated with the file attributes.
The file size is always determined by the actual size of the file
and the only way to change it is to increase by appending more
bytes to the existing file, or to decrease by overwriting with a
shorter file. The file date/time can be more easily changed.
Since changing any of the three date/time values is supported by
Win32 file I/O API, one can write a program to change them. In fact,
there are many utility programs available to do so. Here, we will
discuss the file attributes with greater details.
What is the file attributes?
Although one can say the file size and the file date/time are file
attributes (i.e., any properties associated with a file other than
the file contents), with the more narrow definition and popular
usage, the file attributes are collection of flags stored as a bit
mapped 32-bit quantity which describes various aspects of the file.
The original MS-DOS file attributes had only 8 bits in the file
attributes, the Win32 file attributes are stored as a 32-bit quantity.
Although the exact bit positions of the file attributes are not
officially guaranteed to remain the same by Microsoft, they will
probably never be changed.
Bit 0 Read-Only
Bit 1 Hidden
Bit 2 System
Bit 3 Volume Label
Bit 4 Directory
Bit 5 Archive
Bit 3 (Volume Label) was used in MS-DOS to store the volume label
just like an ordinary file in the directory. Bit 4 (Directory)
distinguish a file from a directory. These two bits cannot be
modified easily. But, the remaining four bits (bit 0, 1, 2, and 5)
can be examined and/or modified by the ATTRIB.EXE utility which is
supplied by DOS/Windows.
The official Microsoft's way to manipulate the file attributes.
Windows 95/98 provide a system utility program, ATTRIB.EXE which
is usually stored in the C:\Windows\command\ directory.
Here is the ATTRIB utility's command syntax
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] filespec [/S]
+ Sets an attribute.
- Clears an attribute.
R Read-only file attribute.
A Archive file attribute.
S System file attribute.
H Hidden file attribute.
/S Processes files in all directories in the specified path.
For example if you want to clear the Archive attribute bit of all
the files in a directory, execute the following command line.
ATTRIB -A c:\mydir\*
The Read-Only attribute.
This bit is useful to make a file write-protected by software.
For example, by setting the \AUTOEXEC.BAT file Read-only, you may
protect the file from accidental deletion. Or you may set a
few files with the Read-only attributes and delete all the files
using a "DEL *" (Delete all) command, the read only files will
not be deleted under normal circumstances. Certain files in the
Win95/98 system are kept as Read-only by default (e.g., the system
registry files).
Before you can delete or overwrite a Read-only file, you must
remove the Read-only file attribute bit.
XXCOPY can force overwriting (or deletion) of a Read-only file by
the /R switch.
The Hidden and System attribute.
The purpose of the Hidden attribute bit is to make the file
invisible in certain applications' file list display. Since many
file applications has the feature to ignore the Hidden attribute
bit, the file with the Hidden attribute bit is not always invisible.
The System attribute bit is probably the least rigorously
defined in its usage. From the early days of MS-DOS, the System
attribute bit has been used in inconsistent manners that the bit
seldom has much meaning. The DIR command treat the System
attribute similarly to the Hidden bit for directory listing.
But, the COPY command does not care whether a file has the System
attribute or not for copying it (Interestingly the DIR and COPY
commands are both "built-in" commands which is implemented within
the COMMAND.COM program).
In most Win95/98 systems, you will find about twenty files in the
root directory which are marked both Hidden and System. These two
attributes are often go hand in hand. But, the choice seems
quite arbitrary.
While the usage of the Hidden and the System attribute bits are
not well defined, the presence (or absence) of these attribute
bits seldom change the actions of most system utilities except for
the DIR and COPY commands, in most case, removing the Hidden and
System attributes on most files do not cause any harm (except
maybe some layer of protection from accidental erasure).
XXCOPY by default (/H0) ignores a file with either Hidden or System
attribute. With the /H switch, you may include files with the
Hidden or the System attributes in XXCOPY's copy action.
The Archive attribute.
The Archive attribute was first introduced by MS-DOS version 2.0
when the XCOPY utility was also created. Therefore, the Archive
attribute is probably best explained by how XCOPY handles the
Archive attribute. The purpose of the Archive attribute was clearly
to quickly determine whether a file requires a back up (archiving).
The Archive attribute is set whenever an existing file is either
overwritten or modified (i.e., renamed or moved to another directory)
by the file system. A new file is usually created with the Archive
attribute set. The idea is to have a utility or application program
to take the responsibility of clearing the Archive bit when a
file is successfully backed up. The next system backup operation
will be made much more efficient by focusing only on the files with
the Archive attribute bit set which are either newly created or
modified in any way since all the Archive attributes are cleared the
last time (i.e., the last backup time).
Incremental Backup using the Archive attribute.
When XCOPY was the only "officially" designated system archive utility
in MS-DOS, the Archive attribute had its usefulness. Or, if only
one backup regime in the system manipulates the Archive attribute bit
and no other programs modifies the bit, the scheme works well.
However, there are many backup and archive utilities that are
capable of clearing the Archive attribute.
Unfortunately, the operating systems do not enforce this
"only-one-program-can-modify-the-Archive-bit" policy. Because of
possible interference with other applications which might clear the
Archive attribute, we consider that the incremental backup scheme
based upon the Archive attribute too risky to depend upon.
Therefore, we do not recommend the use of the /M switch to perform
any system backup operation. For an incremental backup, XXCOPY's
/BI switch performs similar function with more confidence by
comparing the files in the source and the destination with regard
to the file size AND file date/time. If either of the two does not
match (or the file does not exist in the destination), the file will
be copied. This method is nearly as efficient as looking at the
Archive bit.
Other usage of the Archive attribute.
1. You can determine which file(s) an application makes file
changes (creation and modification) in a directory. First,
clear the Archive attribute of all the files in the given
directory and run the application. Then, check to see which
files are marked by the Archive attribute.
E.g.: ATTRIB -A c:\mydir\* // clear the A bit first
Run your application next
XXCOPY C:\mydir\* /A/L // list files with A bit set
2. Say, you have a directory with many files which you want to
copy to a set of diskettes (one diskette cannot hold all of
the files). You can first set all the files with Archive
attribute set first. Then, run XXCOPY /M (or XCOPY /M). The
copy job will terminate as soon as the diskette becomes full.
But the files which has already been copied are cleared of the
Archive attribute. So, run the same XXCOPY /M command again
with a new diskette. This time, the files which has been copied
will be skipped. Just repeat this operation until the files
with Archive attribute run out.
E.g.: ATTRIB +A C:\mydir\* // set the A bit set
XXCOPY C:\mydir\* A:\ /M // copy files with A bit
XXCOPY C:\mydir\* A:\ /M // repeat for next diskette
... // continue until all files
... // are copied.
Full Backup using the Archive attribute.
We have stated that the use of the Archive attribute is not suitable
for a reliable incremental backup. However, once we abandon the
notion that the Archive attribute serves as a persistent marker, it
becomes even more useful. Yes, the Archive bit as a temporary marker
can be quite convenient. The example in the preceding section of
directory-copy to a set of diskette is a backup in a small scale.
When you run Microsoft's ATTRIBUTE utility,
ATTRIB +A C:\* /S
You will encounter the following messages:
Not resetting hidden file C:\WINDOWS\...
...
Sharing violation reading drive C
Abort, Retry, Fail?
In this case, entering "F" should let you continue. But, apparently,
the ATTRIB utility treats the "Fail" option as "Abort". This is
provably a bug in the Microsoft program.
Well, XXCOPY will do what Microsoft fails to do.
XXCOPY C:\* /S /AA
The /AA and /AZ switches make XXCOPY to perform the same function
similar to the ATTRIB utility does except it does a better job.
XXCOPY's /AA switch sets (/AZ clears) the Archive attribute bit
including the hidden files (it has automatically set the /H switch
to include hidden files) and handles share-violation gracefully.
If you need speed, you may suppress the console output by /Q or /Q2.
XXCOPY C:\* /S /AA /Q ;shows only the files which changes
XXCOPY C:\* /S /AA /Q2 ;shows only statistics at the end
After setting the Archive attribute bit of all the files in the
volume, you can start repeated backup using the /M switch
XXCOPY C:\* T:\mybackup /S /M /H ...
(change the target media when it is full and try again)
You may apply the same basic technique to a full-scale volume backup
using the Archive attribute. This is quite useful when you are
backing up a large volume into smaller removable medium
(e.g., CD-R, CD-RW, Tape-based file system, or even floppy disk).
If you have an AutoLoader tape drive (e.g., HP SureStore 12000),
a working batch file example based on this scheme is available at
http://www.datman.com/tbul/dmtb_038.htm.
List of XXCOPY's file attributes related switches.
Archive bit
/A0 Cancels *ALL* /A, /M, /AT, and /AX switches.
/A Excludes files without Archive bit set
/AC Ignores the Archive bit (always clears Archive bit)
/M Excludes files without Archive bit set (clears Archive bit)
/AA Sets the src file archive bit (without actually copying)
/AZ Clears the src file archive bit (without actually copying)
Note: Both /AA and /AZ implicitly set /H (can be overridden)
Hidden and System bit
/H0 Excludes files with Hidden or System Attributes bits (default)
/Ho Excludes files without Hidden or System Attributes bits.
/H Ignores the Hidden or System Attributes bits
Destination Read Only bit
/R0 Excludes a file when it exists in dst as read-only (default)
/R Allows overwrite/delete of a read-only file if necessary
Destination file attributes
/K0 Keeps H-bit and S-bit, sets A-bit, clears R-bit (default).
/KS Keeps the source attributes including the read-only bit.
/KD Keeps the attributes of destination (overwritten) file
/KN Sets the destination attributes to normal (only the A-bit)
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #07
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: XXCOPY's Handling the case of Cyclic Copy
Date: 2004-12-18 (revised)
====================================================================
What is a Cyclic Copy?
Try this with Microsoft's XCOPY (not XXCOPY).
XCOPY C:\ C:\temp\ /S
You will be greeted by the following message:
Cannot perform a cyclic copy.
A cyclic copy refers to the situation where the source directory
contains the destination directory. Since the destination directory
is part of the source, the copying process eventually starts copying
the destination directory to a deeper portion of the destination.
This process will continue until, of course, the finite disk space
eventually runs out.
To avoid this condition but to achieve the objective, one can
specify a temporary destination which is on another volume (e.g.,
D:\temp\) and later copy the temporary destination to the final
destination, and delete the temporary directory at the end.
The safety net against a Cyclic Copy:
Smart programs such as XCOPY have a detection mechanism to avert
this disastrous situation.
In many cases it is prudent for the copy utility to detect and avoid a
cyclic copy. After all, most such cases are simply a user mistake.
Therefore, that was certainly adequate for XCOPY. That's Microsoft.
But, in other cases, you just want to create a copy of the whole
volume into another subdirectory (of course, by excluding the
destination).
Cases where a Cyclic Copy is useful:
A Cyclic Copy is certainly useful with a combination with other
switches such as /TR0 (create corresponding zero-byte files) or
/T (make a directory tree without files).
Or, you may be tempted to make a collection of certain data files
into one directory:
XXCOPY C:\*.doc c:\my_word\ /S
Of course, it is senseless to let the recursive meltdown to occur
by allowing the freshly copied files in the destination to partake
in the copy process. By now, it is quite apparent that what we
really need is a mechanism to cut off this vicious cycle in the
process.
Enter XXCOPY's new switch for Cyclic Copy.
XXCOPY comes with a few variations to handle the cyclic copy case.
/CC Warns you for a cyclic copy case and gives you a prompt
where you may terminate the process immediately, or
you may let XXCOPY continue by adding the destination
directory in the exclusion list.
/CCY Continues the copy operation by automatically adding
the destination directory in the exclusion list without
prompting the user (as if you typed "Y" at the prompt).
/CC0 Terminates the copy operation unconditionally without prompt.
This is the old XCOPY behavior --- hardly useful but if
you want to emulate XCOPY, you may do so with this switch.
A few interesting examples taking advantage of the /CCY feature:
XXCOPY C:\*.doc C:\my_word\ /CCY /S
This example collects directories which contains .DOC
files in the destination with the .DOC files.
XXCOPY C:\*.doc C:\my_word\ /CCY /SX
This is a variation of the fist example. It uses XXCOPY's
handy /SX switch. It gathers all .DOC files from the entire
volume and saves them in a flattened directory. If you have
little idea what a "flattened directory" is, just try it
and examine the destination. You will see what it is.
XXCOPY C:\ C:\skeleton\ /CCY /T
This gives the whole volume tree (except the \skeleton
itself) inside the destination without files.
XXCOPY C:\ C:\summary\ /CCY /E /TR0
This one includes files without copying the file contents
(creates zero-length files corresponding to the source).
These operations are not possible using Microsoft's XCOPY.
Incidentally, the explicit /CCY suppresses the warning message:
"Detected a cyclic copy (the source includes the destination)."
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #08
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: Short names made by Win95/98 and by WinNT/2K/XP
Date: 2003-10-14 (Revised)
====================================================================
In our earlier article, XXTB #03, we discussed the subtle problem
of long and short filenames commonly encountered by Windows users.
The problem has been widely known and various solutions have been
devised to handle most such cases. XXCOPY can handle such cases
correctly in most cases.
Unfortunately, when you mix the two types of OS in operation, one
more potential problem may arise.
About the various Windows OS.
Although all Windows operating systems except early ones (Win 3.x)
support long filenames, there is a subtle difference in the
algorithm of alias synthesis by the various OSes. The difference
may adversely affects XXCOPY's effort in preserving the short
filename.
First, let us examine the difference. Windows 95 and 98 use a
straightforward scheme in picking up the short name alia, whereas
Windows NT4, NT5 and 2000 add a little twist in the way the numeric
tail is generated.
It is easy for anyone to observe the filename related idiosyncrasies.
Just pick a file and repeatedly copy it in a directory under a series
of long names having the same beginning. For example:
mkdir c:\temp
copy c:\autoexec.bat c:\temp\mylongname1
copy c:\autoexec.bat c:\temp\mylongname2
copy c:\autoexec.bat c:\temp\mylongname3
copy c:\autoexec.bat c:\temp\mylongname4
copy c:\autoexec.bat c:\temp\mylongname5
copy c:\autoexec.bat c:\temp\mylongname6
copy c:\autoexec.bat c:\temp\mylongname7
copy c:\autoexec.bat c:\temp\mylongname8
copy c:\autoexec.bat c:\temp\mylongname9
Then, using an appropriate tool, examine the destination directory.
The following table shows the result of the copy operations in
Windows 95/98 and the Windows NT/2000/XP variations.
Longname Windows 95/98/ME Windows NT4/2K/XP
----------------------------------------------------------
mylongname1 MYLONG~1 MYLONG~1
mylongname2 MYLONG~2 MYLONG~2
mylongname3 MYLONG~3 MYLONG~3
mylongname4 MYLONG~4 MYLONG~4
mylongname5 MYLONG~5 MYA476~1
mylongname6 MYLONG~6 MYA486~1
mylongname7 MYLONG~7 MYA496~1
mylongname8 MYLONG~8 MYA4A6~1
mylongname9 MYLONG~9 MYA4B6~1
Whereas the Win9x OSes use a simple decimal number in the numeric
tail, the WinNT family OSes follow the same pattern only in the
first four cases. After that, they start using a 4-digit
hexadecimal number in the middle of the 8.3 name as the
distinguishing part (only the first two letters remains the same).
The hexadecimal value is probably a hash value for the string to
supposedly shorten the filename matching operation which could be
very time consuming. Microsoft programmers chose to keep the first
four match done numerically for the sake of compatibility to the
Win9X systems. What they failed to realize is that they allowed
only the first four such names for compatibility.
The adverse effect of the two alias algorithms.
As long as you use XXCOPY in a homogeneous environment where
the files are generated under one OS, XXCOPY can preserve the
short name. But, when you have a mixed environment (e.g., with a
dual-boot system), you may copy a directory with many similar
names which were created under one OS and then perform a directory
copy operation using XXCOPY under the other OS, XXCOPY may not be
able to preserve the short name.
One consolation is that the great majority of files will receive
the correct short name alias using XXCOPY since the numeric tail of
the first four aliases in a directory are common in all Windows OSes.
Therefore the problem should be quite rare. Ironically, if your
system has many Microsoft software packages, you will find quite
a few directories which all start like:
"\Program Files\Microsoft xxxxx"
One can argue that exactly because it is so rare, this phenomenon
would not be widely known. Therefore, when the rare problem occurs,
it will take many agonizing hours for the user to discover the
cause of the problem.
Then, what happens with XXCOPY?
Since XXCOPY does not access the raw directory contents in the
process of preserving the short name alias, its magic does not work
all the time. We cannot do much about this problem without making
the XXCOPY utility breaking the rules of good programming practice.
At least we can list the situations where the potential problem may
arise and how you can it.
1. Stay within the 8.3 naming convention if possible.
2. Stay away from a dual-boot system if possible.
3. If you have a dual-boot system and you switch the OS from
time to time, make sure a directory is written exclusively
under one OS if possible.
4. Finally, when you have to copy a directory, use XXCOPY and
perform the copy operation under the same OS in which the
files in the directory were created.
5. In a networked environment with different types of OS between
the source and the destination directories, expect the worst.
Note that although it is ideal that when you copy a directory,
all the files in the destination should be identical to those in
the source, in most case, it is not the end of the world. As a
matter of fact, in most cases, the discrepancies in short names
do not cause any problem. As long as the files and directories
that are affected by this problem is "non-system" files, the
problem would be benign if present at all.
In the case of Windows 95/98, the most well documented problem
which are associated with the unmatched short name is a few
directory and filenames which are stored in their short name
alias in a few critical cases in the system registry. Since
Windows 95/98 references these files at the system initialization
time (locating and loading VxD files using short names), the
difference would be life and death (that is, success and failure
in system initialization).
A final advice with XXCOPY:
If you have a large number of collided aliases (where the short
name distinctions are made by the synthesized numeric tail only),
and you are copying across OSes (from Win95/98 to WinNT/2000/XP
or vice versa), we suggest you turn off XXCOPY's short name
preservation switch by /NX0 in order to avoid the time consuming
and futile effort by XXCOPY.
[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #09
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: Worldwide Network of Download Sites for XXCOPY
Date: 2001-07-10
====================================================================
If you have difficulties downloading the XXCOPY freeware copy
from our own server, select an ftp site which is close to you.
Our sincere thanks go to Simtel.Net which has the world-wide
network of mirror sites.
Unfortunately, due to the agreement with Simtel.Net we are unable
to provide direct links to the files. You should visit the
following page which has the actuali links of the mirror sites:
Simtel.Net List of Mrror sites
XXCOPY Freeware ver 2.60.0 (xxfw2600.zip)
FTP:// download sites
________________________________________________________________________
US, ALL (primary) US, Arizona US, Georgia
US, Illinois US, Indiana US, Massachusetts
US, Missouri US, New York US, Oklahoma
US, Oregon US, Pennsylvania US, Virginia
Australia Austria Belgium
Brazil Bulgaria Canada
Czech Republic Denmark Finland
France Germany Hong Kong
Hungary Italy Japan
Netherlands Norway Poland
Portugal Russia Singapore
Slovenia South Africa South