Lou said:
I am xxcopy to go against the file I listed below. Every time I run it
no matter what permutations I try, it always copies directories I didn't
ask for, like windows for instance. I even tried just /s option and to
no avail. Can someone please help?
I am running this command: xxcopy -cflouxxcopy.txt
and here is the file contents of louxxcopy.txt:
c:\ :: source
g:\Backup :: destination
/s :: subdirectories
/h :: copy system and hidden files
/bi :: back-up incrementally
/y :: supress overwrite prompt
/r :: overwrite read-only files
/q2 :: supress excluded files during output
/pb :: process bar
/xC:\WINDOWS\* :: exclude the following...
/x*.sys
/x*.com
/xC:\ntldr
/xC:\Games\*
/x"C:\My Music\*"
/xC:\Oracle\?\*
/x"C:\System Volume Information\*"
/x*\temp\*
/x*\cache\*
/x*.tmp
/x*.mpg
/x*.mp3
----------------
I believe Lou's problem might be due to a (mis)understanding
of XXCOPY's exclusion rules (which is not an easy read).
The complete syntactic rules about XXCOPY's exclusion feature
are spelled out in the following page:
http://www.xxcopy.com/xxcopy05.htm
Admittedly, XXCOPY's exclusion specifier has messy syntactic
rules. This reflects our desire to cover more cases in
the use of wildcard --- if you don't understand all of the
rules, you need not use the one which is not clear to you.
Basically, the ending of the exclusion specifier tells a lot
about the class of files/directories that are excluded.
Let me just point out the problematic parts in the rules:
/xC:\Windows\*
this excludes the first-level files in the directory.
e.g., C:\windows\win.ini
C:\windows\system.ini
C:\Windows\explorer.exe
More specifically, it does not exclude files in the 2nd-level
or deeper subdirectories (such as c:\windows\system32\desktop.ini).
That is, the following two are distinct and different:
/xC:\Windows\* (1st-level files only
/xC:\Windows\*\* (everything in the C:\Windows\ directory)
Let me explain how this thing came about.
XXCOPY views a directory having two types of components
in its immediate contents:
1. files
2. subdirectories
To specify only files (not files in subdirectories)
/xC:\Windows\*
To specify only subdirectories (no 1st-level files)
/xC:\Windows\?\*
(naturally, when we say "subdirectories", everything inside
the subdirectories (both files and sub-subdirectories).
-----------------------------------------------------------
Note that the ..\?\* notation used in this context has
nothing to do with the "?" character interpreted in the
ordinary wildcard usage --- matches one character.
Rather, the ending ..\?\* is to denote subdirectories
but not the 1st-level files (the reason for the symbol-
overloading is that all other characters are valid in
filename and cannot be used to attach special meaning).
------------------------------------------------------------
To specify both files and subdirectories (i.e., both of the
above two types --- everything inside the directory),
you may specify it by either:
/xC:\Windows\
/xC:\Windows\*\*
(the above two are completely interchangeable).
In general, XXCOPY uses the funny notation, ..\*\..
to include subdirectories for the item (somewhat
parallel to the common "/S" switch. As a matter of fact,
we invented this notation in order to satisfy our desire
to let an item to cover its subdirectories in the spirit
of /S.
The following two lines will show the contrast between
the two:
/xabc\
/x*\abc\
Here, the first item specifies the directory "abc" which
is immediately below the source base directory.
The second one specifies any directory named "abc" in
any level of subdirectories under the source base directory.
------------------------------------------------------------
It is in the spirit of /S except that if we were to add /S,
it would modify the source specifier, not the particular
exclusion item. But, if we were allowed to use parentheses
to limit the scope, it would be like (/xabc\ /s) --- but
such a syntax would be too confusing, hence we invented
the ..\*\.. notation to denote the case which applies to
the respective subdirectories. /x*\abc\ is cleaner.
------------------------------------------------------------
In one occasion, Lou did use the \?\* notation:
/xC:\Oracle\?\*
This exclusion item applies to *ALL* subdirectories inside
the C:\Oracle\ directory but does not apply to the files
which are located immediately below C:\Oracle\.
My guess is that Lou was probably thinking that the following
two are the same
/xC:\Games\*
/xC:\Games\
As I said, the above two are not the same.
On the other hand the following two are equivalent and
completely interchangeable
/xC:\Games\
/xC:\Games\*\*
In conclusion, Lou's problem will probably go away if he
changes the XXCOPY command by replacing the sequence of
backslash-asterisk by just a backslash (in five
instances except for the C:\Oracle\?\*.
One last comment: other than the misunderstanding of the
trailing asterisk, Lou's command file is quite solid.
To make it even more robust, consider adding the /ILS and/or
/ILD switch which checks the source and destination volume
label respectively (these features are recently added).
Kan Yabumoto
The Author of XXCopy