Saturday, March 30, 2013

Delete Files Older Than a Number of Days From DOS Read more at http://technicallyeasy.net/2011/02/delete-files-older-number-days-dos/#vqfrZB4vjOpMzy2e.99

From: http://technicallyeasy.net/2011/02/delete-files-older-number-days-dos/


dfsdfThere is a small executable called ForeFiles that can easily allow you to get the files in a directory that meet certain time criteria. In my case I want to find all files that were older than 7 days.

To do this, I added the following command to a batch file:

forfiles.exe /p D:\Files /s /m *.* /d -7 /c "cmd /c del @file"

The above line executes the forefiles.exe program with the following parameters:

Parameter Description

  • /p This parameter specifies the path that contain the files I wish to delete.
  • /s This parameter tells the program to recurse into any subfolders to look for additional files.
  • /m If you want to specify a specific file type, this parameter will allow you to limit the search to specific files, such as *.doc for Word documents. In my case, I looked for all files (*.*).
  • /d This one is the key parameter – it specifies the last modified date value. In my example I specify “-7? which indicates that the files need to have a modified date 7 days less than the current date.
  • /c This is the command that I execute on the files found by the program. The delete command is executed in a command window for each file.


Read more at http://technicallyeasy.net/2011/02/delete-files-older-number-days-dos/#vqfrZB4vjOpMzy2e.99


Related

No comments:

Post a Comment

Popular Posts