Solved

delete files through a batch process based on access time

Posted on 2004-04-13
2
518 Views
Last Modified: 2010-04-13
Hi
I want to set up a script in windows 2k, to scan certian dir and file extensions based on their last access time (say a week ago). I know how to do this on unix machine. I am wondering if any one can help on this.
thank you
sarma
0
Comment
Question by:schilukuri
  • 2
2 Comments
 
LVL 7

Accepted Solution

by:
wtrmk74 earned 100 total points
ID: 10819580
Download ForFiles.EXE from the windows 2000 Resource Kit Here
http://www.dynawell.com/reskit/microsoft/win2000/forfiles.zip

Download to your WINNT Directory !

Info on basic setup and functionality:
http://www.microsoft.com/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/Default.asp?url=/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/forfiles.asp

Then open NOTEPAD and copy this text:
------------------------------------------------------------------------------------------------------------
@Echo OFF
Echo Deleting files older than 7 days in the specified directory !
Echo ...........................................................
Echo Are you ready to begin file deletion ?
Pause
forfiles -pc:\TestFolder -s -d-7-c"cmd /c del ""@FILE"" /Q /F"
Echo You have successfully deleted the specified files in your directory !
Pause
Exit
------------------------------------------------------------------------------------------------------------
Save As....filedel.bat in your C:/Drive
and then Run from Command Line:    %SystemDrive%/filedel.bat

I created an example based on
DRIVE                         = C:
Folder Name               = TestFolder
Search Subdirectories  = -s
Date Range                 = -7
Command                   = -c"cmd /c del "
Variable                      = @FILE
Switches                     = /Q quiet , F/ force

Have fun
wtrmk74
0
 
LVL 7

Expert Comment

by:wtrmk74
ID: 10846903
Glad it all worked out !

Take Care
wtrmk74
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question