Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple W2K Script Help Please 1

Status
Not open for further replies.

Donkey1

Technical User
Sep 3, 2002
91
GB
My knowledge of scripting is very basic and would like to ask for some help if it is possible.

What I would like to do is run a simple script (.bat file) on 2 W2K machines that would automatically delete some files that are over a certain date old e.g. any file over 2 months old.

The files are always held in the same dir and always have the same extension .bak

Would be grateful if some one could point me in the right direction.

Thanks....Andy.
 
Hello Donkey1,

You can use forfiles.exe from resource kits. Look at its help file or issue
[tt]forfiles -?[/tt]
for syntax.

For instance, to [1] delete *.txt files [2] in certain path d:\test [3] including subdirectories for files [4] with date more than 30 days old from today, the line in the batch is something like this:
Code:
forfiles -pd:\test -s -m*.txt -d-30 -c"%comspec% /c del @FILE"
regards - tsuji
 
Thanks guys for your help.

Tsuji, your cmd line script did the trick - works a charm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top