Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have 4 servers (Windows 2003 R2), each with a log-directory with thousands of log-files. I have written a log-viewer that collect log-files within a date range and show them in a grid. But this is rather slow as the number of log-files grow fast.

If I could schedule to move all files older than N days to an zip-archive I think the logviewer should be much faster. I'm not good at write bat-files. Any suggestions ?

share|improve this question
What type of logs? – Zoredache Oct 29 '09 at 6:56
It is custom logs in textfiles for a server application written by our team. It as timestamp and a message, maybe an exception string etc. – berocoder Nov 1 '09 at 17:45
up vote 1 down vote accepted

You should be able to use forfiles:

forfiles /m *.log /c <zip up here> /d -N

The /d switch tells forfiles to only consider files older than N days. Of course, you need to replace N with a nice number.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.