Jump back to the top page Jump back to the top page

 What is XXCOPY ?
 F A Q 
 About Us (Pixelab) 
On-Line Manual 
XXTB #001 
XXTB #002 
XXTB #003 
XXTB #004 
XXTB #005 
             . . .  


©2016 Copyright

 All rights reserved  
    [ Table of Contents ] [ Show as Detached ] [ >> ]


    From:    Kan Yabumoto           tech@xxcopy.com
    To:      XXCOPY user
    Subject: The file removal features in XXCOPY
    Date:    2000-11-17  (revised)
    Why are we always short in the storage space?
      No matter how big your hard disk is, it gets full sooner or later.
      Microsoft is often blamed for their "bloatware".  But, here is
      another theory.  There are just more programs which create files
      than those which delete files.  If you look at common applications,
      usually they offer more ways to create files than to destroy them.
      Therefore, to maintain a healthy equilibrium between the file
      creation and the file deletion, we need to put more conscious
      effort in file removal.  In the case of XXCOPY, it has been used
      primarily for file copying, and not much for file removal.
      Now, starting with Version 2.25, XXCOPY has a whole new set of
      file removal features.
    File removal using a file copy utility?
      Why are we adding to XXCOPY more features which are not directly
      related to the file-copy function?  A good question.  Why not
      produce a separate file-delete utility?  That makes sense if you
      expect a simple one.  But, for that matter, you already have
      DELTREE from Microsoft.  Again, XXCOPY fills the void.
      Once you learn XXCOPY's rich set of file selection scheme in
      various file copy operations, you would want the same kind of
      power in file removal operations as well.  Therefore, instead of
      making a very similar program for file deletion, it is more
      natural to use the exact same file selection mechanisms of
      XXCOPY for file removal operations.  The notion of a file copy
      utility with a patch to handle file deletion should be thrown
      away.   It is only in its name, XXCOPY, which may mislead you on
      what it is capable of.  It is now a general purpose file management
      tool and the file removal feature is certainly an important one.
      In totality, we believe that you will spend less time learning the
      new features in the enhanced XXCOPY utility than you would spend
      in studying a brand new file delete tool.
    The design principle of XXCOPY's file removal.
      We added just a few file removal functions which combine well with
      existing framework of XXCOPY's file selection schemes.  The new
      file removal functions all start with the letter R (for removal).
       Switch   Mnemonic          Files to be removed
        /RC   Remove-after-Copy   files in source after a successful copy
        /RS   Remove-Source       files in source which qualify
        /RD   Remove-Destination  files which qualify to be overwritten
        /RX   Remove-Extra        files which do not exist in the source
        (More minor variations are specified by optional third letter).
      Any of the above switches modifies the basic operation from file-
      copy to file-removal.  But, most other switches which engage in
      the file selection process apply equally to the file removal case.
    The actions by the four variations in the file removal.
      With the first two variations (/RC and /RS), the file removal takes
      place in the source directory whereas in the last two cases (/RD
      and /RX), the operation takes place in the destination directory.
      The file copy operation is performed only with the first variation
      (/RC) and no copy is performed by the other three (/RS, /RD, /RX).
      Therefore, the designation of the source and destination for the
      command arguments (the non-switch parameters, ones without a slash)
      is admittedly weak.  But, in light of their origin being the file
      copy operation, they still carry some nuances.  The reference
      (destination) directory plays a vital role in file selection.
      /RC  (Remove-after-Copy)
            This switch first performs a regular file copy operation,
            and then removes the source file when the copy is successful.
            In essence, it is a file move operation.  Nearly all common
            XXCOPY switches designed for file copy apply in this case.
      /RS  (Remove-Source)
            This switch removes the source file without a copy action.
            In some cases, you specify only the first argument
            (the source specifier) without the destination.  However,
            there are many instances where you select files based on
            the relationships to the files in the reference (destination)
            directory.  For example, you may delete the files in the
            source that are older than the one in the destination.  You
            will probably use this switch more often than the other
            switches in this group.
      /RD  (Remove-Destination)
            This switch removes the files which would normally be
            overwritten.  The file selection process is exactly the
            same as in the cases of file copy.
      /RX  (Remove-Extra)
            This switch removes the files in the destination whose
            corresponding file is not present in the source directory.
            This command is somewhat similar to the /Z switch which
            accompanies regular file copy operations.  The difference
            with the /Z and /ZY commands is, of course, these commands
            carry out file copy actions whereas /RX does not copy at all.
    The cases with /RD and RX --- Cautions.
            When you use the /RD or /RX switch, there are a few things
            you should remember.  Although the focus of the action is
            on the files which are to be removed, when these files are
            in the destination, many of the XXCOPY switch parameters
            does not work with the files in the destination directory.
            For example, when you specify /RD (remove destination) with
            /DB#4 (files more than 5 days old), the file date in the source
            is checked, not the one that would actually get removed.  This
            is because the /RD switch borrows XXCOPY's basic file-selection
            mechanism to determine which source-destination file pair
            to operate on.  This particular operation happens to be to
            remove the file in the destination rather than the one in
            the source.  It may be a little confusing but we can't help.
            It may be even more true with the /RX switches where the
            files are removed simply by the virtue of being in the
            destination as extra.  In this case, your additional switches
            such as /A (files with Archive bit set), /DB#4 (older than
            four days), or even /DA (when the file in destination is
            older than in the one in the source).  Remember, with the
            /RX switch, the files to be removed has no counterpart in
            the source!!!  So, all these switches will be just ignored.
            Our recommendation is that you should use the /RD and /RX
            switches for relatively simple file selection cases only.
            When you start adding many file selection switches, we advise
            you rewrite the XXCOPY /RD command using /RS/U with the source
            and destination reversed.  Similarly, an XXCOPY /RX command
            can be written using /RS/BB with source and destination
            reversed.  By having the files for removal in the source
            side in the command, you will have all the switches which
            applies to the files which would actually be removed.
    Convenient shortcut:
      /RMDIR  Removes the specified directory including the files and
              subdirectories inside.
      This /RMDIR switch makes XXCOPY to behave like Microsoft's
      DELTREE utility.  The following two commands are very similar.
        DELTREE c:\mydir
        XXCOPY  c:\mydir  /RMDIR
      However, the power of XXCOPY become evident when it is combined
      with other switches.
        XXCOPY  c:\mydir  /RMDIR /DA:2000-04-01 /Y /X*.doc
          This command removes files inside the directory which are made
          on or after the specified date but avoids deleting .DOC files.
    Examples of the file removal switches.
      xxcopy c:\mydir\myfiles.*  c:\destination\  /RC
        The files which match the pattern, "myfile.*" in c:\mydir\ and
        all of its subdirectories will be deleted after copying.  If
        copy fails for any reason, the files in the source will *NOT*
        be removed.  It behaves essentially like the MOVE command.
      xxcopy c:\mydir\myfiles.*  /RS /S /H
        It is similar to DELTREE, subdirectories are specified.  The
        files which match the pattern, "myfiles.*" in c:\mydir\ and all of
        its subdirectories will be deleted.  No copying will take place.
        The /H switch is needed if you want to include hidden and/or
        system files.
      xxcopy c:\mydir\myfiles.*  c:\reference\   /RS /S /H /DB
        The /DB switch uses the second directory (c:\reference) which
        supplies the filenames to compare the file time against the
        files in the source.  The files in the source which are made
        before (/DB stands for DATE:BEFORE) their counterpart in
        destination will be removed.  In this case, the files that
        do not exist in the reference directory will also be removed.
      xxcopy c:\mydir\myfiles.*  c:\reference\   /RS /S /H /DB /U
        This is exactly same as the one above except this has the
        /U switch (update --- applies only to files that exist in the
        destination) will not remove files that do not exist in
        the destination.  This is a quite useful combination to remove
        those files whose new version exists in the reference directory.
      xxcopy c:\mydir\myfiles.*      c:\reference\   /RS /S /H /U
      xxcopy c:\reference\myfiles.*  c:\mydir\       /RD /S /H /U
      xxcopy c:\reference\myfiles.*  c:\mydir\       /RD /S /H
        Here, three variations of file removal actions are specified.
        But, they achieve exactly the same result.  The first one
        removes the qualified files in the source (and its
        subdirectories) if they exist in the reference directory.
        Please note the change in the position of the c:\mydir
        argument in the second and third examples above.  In the
        second example, the /U is superfluous because the /RD switch
        (file in the destination that would be overwritten) implies
        that in order to be overwritten, its counterpart must exists
        in the source.  The third example proves that /U in the second
        example was not necessary.  On the other hand, /U must be
        in the first example; without it, the files in the reference
        directory will be totally ignored.
      xxcopy c:\reference\myfiles.*  c:\mydir\       /RX /H /S
      xxcopy c:\reference\           c:\mydir\       /RX /H /S
        These examples eliminate all files in the destination whose
        counterpart does not exist in the source directory will be
        removed.  They resembles the /Z switch where qualified files
        will be overwritten by the source files.
      xxcopy c:\mydir\myfiles.*  c:\destination\     /RS /H /S
      xxcopy c:\mydir\myfiles.*                      /RS /H /S
        These two will result in the same action, namely, removing
        the matched files in the source and its subdirectories.
        In the first example, since there is no switches which
        references the second directory specifier (c:\destination),
        the second argument was totally unnecessary and ignored
        (without warning).
      xxcopy c:\mydir\myfiles.*   /RS /S /H /DB#7
        Remove files which match the template in the source and
        its subdirectories which are more than seven days old.
      xxcopy c:\       /RS /S /H /DA:2000-02-01 /DB:2000-02-29
        Remove all files which were made during the month of
        February 2000.
      xxcopy c:\mydir\  c:\backup\   /RS /S /H /BI
        Remove files in c:\mydir\ and its subdirectories that are
        identical in date and size.
      xxcopy c:\mydir\               /RS /S /Ho
        Remove all hidden files in c:\mydir\ and its subdirectories.
      xxcopy c:\                    /RS /A
        Remove all files in the root directory with the archive bit set.
      xxcopy c:\mydir\*.jpg         /RS /Xmydear.jpg
        Remove all .JPG files but keep mydear.jpg.
    Confirmation prompts.
      Since file removal is a serious business, XXCOPY always asks you
      for confirmation before removing a directory.  As a matter of fact,
      XXCOPY provides two levels of confirmation prompts.
      1.  On each directory to process.
      2.  On each file to delete.
      Of course, for batch file execution, you normally do not want such
      confirmation.  Also, to allow flexible control, the prompt includes
      a choice to eliminate further confirmation in the current and
      subsequent items.
      Unfortunately, the rules for the confirmation prompts are quite
      complicated because of the many cases involved.  You may skip the
      following three sections for now and come back to read the gory
      details later.  Just remember that you can suppress the Yes/No
      prompts in the two levels by /PD0 and /Y, respectively.
    Directory-removal confirmation prompt.
      Before each directory to process, you will be given a chance to
      skip the directory by a prompt with
       Y  for Yes (Yes, process the current directory for removal)
       N  for No  (No, skip the current directory and go to the next one)
       A  for Yes for All remaining directories (suppresses subsequent prompts)
       R  for Yes for the current and Remaining siblings and its subdirectories.
       S  for Yes for the current and its subdirectories.
      The Y(es) and N(o) inputs are the most obvious cases.  They apply
      to the current directory only.  The A(ll) input is also pretty easy
      to understand.  It applies the current and all subsequent cases by
      and suppresses the prompts once for all.  The R and S inputs are
      partial suppression and a bit confusing: When you type R, the current
      directory and remaining (sibling) directories will be removed without
      further prompting.  But, the effect of R response will not affect the
      parent directory level.  When you type S, it is the most restrictive
      response of all.  It affects the current and its subdirectories only.
      The next directory in the same level will not be affected by the R
      Here are how to suppress and unsuppress the directory-removal prompts.
        /PD   Enables the directory-level prompt.
        /PD0  Disables the directory-level prompt.
    File-delete confirmation prompt.
      Another level of confirmation is on a file-by-file basis.  Before
      each file is to be deleted, you will be asked by a prompt with
       Y  for Yes (Yes, delete this file)
       N  for No  (No, skip this file)
       A  for Yes for All remaining files (suppresses subsequent prompts)
      Here are how to suppress and unsuppress the file-delete prompts
      (applicable for /RS, /RD, and /RX cases).
        /Y   Disables the file-delete prompt.
        /-Y  Enables the file-delete prompt.
        /Y0  Enables the file-delete prompt (same as /-Y).
    More confirmations on /RC (Remove-after-Copy).
      The /RC switch is a special case in the removal switch group.  It
      performs a file copy action before the source file is deleted.
      As with other file-copy functions, /P insert a confirmation prompt
      (Y/N/A)? to perform the copy operation first.  The regular rules
      for the /P switch applies exactly in the case /RC switch.  There is
      one more case of (Y/N/A)? prompt which may appear with the /RC
      operation --- file-overwrite confirmation.  Just like the regular
      file copy operation, when there is a file in the destination, you
      will be asked for confirmation.  The /Y, /-Y, and /Y0 for /RC switch
      control the suppression of the file-overwrite prompt rather than
      the delete-after-copy prompt.  Therefore, we need one more switch
      convention to enable/disable the file-delete confirmation prompt:
        /RC  (Remove-after-Copy) enables Y/N prompt on remove (same as /RCP)
        /RCP (Remove-after-Copy) enables Y/N prompt on remove
        /RCY (Remove-after-Copy) suppresses Y/N prompt on remove
        The optional third letter (P or Y) specifies the removal prompt.
      Similarly, the other variations in the file remove operation also
      accepts the third letter (to be symmetrical to the /RC switch).
        /RS  (Remove-Source)   enables Y/N prompt on remove (same as /RSP)
        /RSP (Remove-Source)   enables Y/N prompt on remove
        /RSY (Remove-Source)   suppresses Y/N prompt on remove
        /RD   (Remove-Dest)    enables Y/N prompt on remove (same as /RDP)
        /RDP  (Remove-Dest)    enables Y/N prompt on remove
        /RDY  (Remove-Dest)    suppresses Y/N prompt on remove
        /RX   (Remove-Extra)   enables Y/N prompt on remove (same as /RXP)
        /RXP  (Remove-Extra)   enables Y/N prompt on remove
        /RXY  (Remove-Extra)   suppresses Y/N prompt on remove
      The /Y and /-Y switches also control the prompt for file remove
      action for /RS, /RD and /RXn (not with /RC) switches.
      To undo any of the /RC, /RS, /RD, or /RX switches, append letter zero
      (e.g., /RC0, /RS0, /RD0, and /RX0 respectively).
      The examples given here hopefully show that the file removal
      feature in XXCOPY is merely an extension to other XXCOPY switches
      and basically the same rules apply here.  In the case of file
      removal, probably less than a half of operations use the files
      in the second directory (destination) as a reference where the
      /RS switch is usually selected.  The next common cases involves
      in /RD which is used for elimination of multiple copies of the
      same files.  Although there are some switch combination which
      makes no sense with the file removal cases, many are expected
      to be quite useful.  Since not all of the switch combinations
      are thoroughly tested, there may be some contradictory definition
      of rules (or even actions) may arise during the beta testing.
      If you find an interesting switch combination which is quite
      unique and valuable in common cases, please let us know.  it
      seems that this scheme generates a very large number of
      combinations many of which are not intuitive.  It is entirely
      possible that someone may come across an interesting behavior
      which none else has ever thought of.  Only time can tell.
    [ Table of Contents ] [ Show as Detached ] [ >> ]