![]()
[<<]Message[>>] [<<]Author[>>] Subject [<<]Thread[>>]
Number : 3200 Date : 2002-12-06 Author : Kan Yabumoto Subject : Speaking of file/directory deletion Size(KB) : 3
james sadler wrote: > Using the clone switch from an empty directory will delete > an XP directory nicely. > That is a really valuable feature for me. /CLONE to remove a directory? I never even thought of that as the designer of the tool. While what james calls a "feature" was certainly not by design, I am not totally surprised to hear that experienced users find interesting applications of XXCOPY. I'm just delighted to hear his usage. While I don't argue against that practice, let me show you the more "official" approach to the file and directory removal problem. XXCOPY provides four distinct flavors in removal operations. /RS // remove source (files that matches the qualificaiton) /RC // remove source after copy (equiv. to move) /RD // remove dest. (files that would be overwritten) /RX // remove extra files/direscotires in the dest. Note that the reason why what james suggested works is because /CLONE has the /Z operation which removes extra files and directories in the destination that are not present in the source. This is equvalent to /RX operation with the first directory being an empty one. The most versatile one for a directory removal is the use of /RS switch with optional switches such as /S /H /R, etc. (I look at the /RC operation more like a move operation). The reason for my recommendation of this switch is it can be easily combined with other switches to fine-tune the operation. For example, you may add /DB#60 to limit the deletion to the files that are older than two months, /SZ:1M- files that are larger than 1MB, /SZ:0 zero-length file, etc. The other two variations in the /Rxx series do not have such a capability. As a matter of fact, the /RX operation is the least flexible among the four variations (and the /Z as in the /CLONE operation is just that). Now, that brings us to the often forgotten shortcut, /RMDIR. Just as the /CLONE switch is a versatile combination that is easy to remember for directory duplication, /RMDIR is a convenient starting point for directory removal. It is a shortcut for /RSY/S/H/R/PD/ED0. -------------------------------------------------------- It's designed as a replacement for the popular DELTREE utility that came with Win9X (if you have DELTREE.EXE in your Win9X, you may just copy the utility to your WinXP environment). It should work just fine ---- unlike XCOPY whose tight version-checking makes it unfit for porting it from one version of Windows to another, DELTREE is completely portable. -------------------------------------------------------- xxcopy C:\MYDIR\ /RMDIR As usual, /RMDIR comes with the /PD switch (which is default to /RS anyway) that gives you fine controls of which subdirectories to skip, etc. (we made the Y/N prompt a little fancier). The strength of /RMDIR is that you can put additional file-selection switches (such as /SZ:xxx /DB#xxx). It is also useful with two-directory operation where you delete files from one directory based on what are in the reference directory. The following command line will remove files from the first directory that are common to the two directories (and only when they are exactly the same in the file size and timestamp); xxcopy C:\DIRA\ C:\DIRB\ /RMDIR /BS Or, you may want to delete *ALL* files in the first directory that are common in the two directories; xxcopy C:\DIRA\ C:\DIRB\ /RMDIR /U In a batch file and other context that you know what you are doing, you may use xxcopy \MY_DIR\ /RMDIR /YY // use /YY with care Ciao, Kan Yabumoto
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.