Deleting Files Based on Creation Date (67381)



The information in this article applies to:
    Microsoft MS-DOS operating system 3.21
    Microsoft MS-DOS operating system 4.0
    Microsoft MS-DOS operating system 4.01
    Microsoft MS-DOS operating system 5.0
    Microsoft MS-DOS operating system 5.0a

This article was previously published under Q67381

SUMMARY

MS-DOS versions before 6.x do not provide a direct means of deleting a file based upon its creation date. However, you can perform this function by using a sequence of MS-DOS commands, executed from the directory in which the files to be deleted reside, as follows:
   md newfiles                     (Creates subdirectory NEWFILES)

   xcopy *.* newfiles /d:date      (Copies all files from current
                                   directory created on or after
                                   date to the subdirectory
                                   NEWFILES*)

   del *.*                         (Deletes all files in current
                                   directory)

   xcopy newfiles                  (Copies files from NEWFILES to
                                   current directory)

   del newfiles                    (Deletes all files in subdirectory
                                   NEWFILES)

   rd newfiles                     (Removes subdirectory NEWFILES)
    Please note that this procedure requires enough free disk space to maintain two copies of all of the files in the current directory that will be saved.
With MS-DOS version 6.x the final two steps can be replaced with:

deltree newfiles


Modification Type: Major Last Reviewed: 11/26/2003
Keywords: KB67381