[ Back to Table of Contents ]
[ << ]
[ >> ]
XXCOPY TECHNICAL BULLETIN #07
From: Kan Yabumoto email@example.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:
Microsoft's XCOPY detects this disastrous situation with an error
message. With our XXCOPY, you may continue the normal file copy
operation by excluding the directory that would be cyclic after
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
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)."
© Copyright 2016 Pixelab All rights reserved.