[ Back to Table of Contents ]
[ << ]
[ >> ]
[ Feedback ]
XXCOPY TECHNICAL BULLETIN #07
From: Kan Yabumoto tech@xxcopy.com
To: XXCOPY user
Subject: XXCOPY's Handling the case of Cyclic Copy
Date: 2000-02-11
====================================================================
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:
It is certainly true with a combination with other switches such as
/SZ0 (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 always without prompt.
(this is the default behavior --- compatible to XCOPY).
Note that although the /CC and /CCY action is internally
equivalent to specifying the destination directory using the /X
switch, you must explicitly use the /CC or /CCY switch in order
to continue the copy operation with a cyclic copy condition.
A few interesting examples using /CCY:
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 /SZ0
This one includes files without copying the file contents
(creates zero-length files corresponding to the source).
© Copyright 2002 Pixelab, Inc. All rights reserved.
