Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Feb 2009
    Location
    Evanston, Illinois, USA
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatically deleting old files

    How can I automatically delete hundreds of old files (from before the year 2000) and keep only files with latest saved date ?? Can I use DOS batch files to accomplish this task ??

    Thanks for any help ... Theodore

  2. #2
    Silver Lounger RolandJS's Avatar
    Join Date
    Dec 2009
    Location
    Austin metro area TX USA
    Posts
    1,733
    Thanks
    95
    Thanked 128 Times in 125 Posts
    Probably can. I would pretend DIR was the delete command and experiment until the DIR commands give you exactly what you want -- a listing of the files that would have been deleted if the DEL command was used. After you're satisfied, subsitute DEL for DIR [of course change a switch or two], test on a directory with files you can afford to lose before committing batchfile to the whole data partition.
    "Take care of thy backups and thy restores shall take care of thee." Ben Franklin revisited.
    http://collegecafe.fr.yuku.com/forum...-Technologies/

  3. #3
    5 Star Lounger
    Join Date
    Oct 2013
    Location
    Phoenix, AZ
    Posts
    926
    Thanks
    554
    Thanked 137 Times in 128 Posts
    Quote Originally Posted by Theodore View Post
    How can I automatically delete hundreds of old files (from before the year 2000) and keep only files with latest saved date ?? ....
    Are they in the same folder? If so,
    • Open Windows Explorer.
    • Sort by date.
    • Highlight the first file you want to delete.
    • Then go to the last file, hold down the shift key and highlight the last file you want to delete.
    • All the files you want to delete should now be highlighted. Hit the delete key.

  4. #4
    5 Star Lounger
    Join Date
    Dec 2009
    Location
    S.F. Bay Area, California, USA
    Posts
    735
    Thanks
    15
    Thanked 80 Times in 78 Posts
    To be more precise--

    While holding the shift key down, press the delete key.

    Zig

  5. #5
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Chicago, IL, USA
    Posts
    107
    Thanks
    22
    Thanked 1 Time in 1 Post
    You can do it in a batch file with some advanced commands but it's very tricky. There are some books on advanced batch file programming (including one by Peter Norton) that might be helpful, if you want to put some time into it, or you can google the topic. If you only want to do it once it probably isn't worth the trouble.

    There are also some utilities that will delete files by date. You might look on download.com or another freeware site.

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Theodore,

    This is a piece of cake w/PowerShell

    To find your old files:

    get-childitem -path G:\BEKDocs\*.* -Recurse | where LastAccessTime -lt 1/1/2007 | select fullname, Lastaccesstime

    Substituting your own value for the -path argument, remembering to enclose it in quotes if it includes spaces, and your cutoff date. Note that is a Less Than (-lt) so the date you enter will NOT be listed or deleted only files older than that date. Also note the -Recurse parameter which means that the command will operate on all sub-directories below the main directory you specify in the -path parameter. If you don't want this behavior just remove the -Recurse.

    When satisfied with the list to delete them:

    get-childitem -path G:\BEKDocs\*.* -Recurse | where LastAccessTime -lt 1/1/2007 | foreach ($_) {remove-item $_.fullname}

    If you've never done PS before see: this previous post of mine.

    As always before doing this type of operation make sure you have a COMPLETE BACKUP or IMAGE of the directory tree you are going to operate on. Preferably a complete Drive Image!

    HTH
    Last edited by RetiredGeek; 2015-08-19 at 17:43.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. The Following User Says Thank You to RetiredGeek For This Useful Post:

    Fascist Nation (2015-08-19)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •