Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've looked around here for an answer to my question but it doens't look like anyone has so far got there.

I'm looking for a way to selectively DELETE files from a directory, so I have; Every file in the last 7 days one file for every 30 days.

So in effect I've got last week and then a file for each month. I'd like to use a batch script to do the delete or a GUI, I don't mind, but it needs to be something I can schedule. At the moment I'm hand tweening out the files...

Most of the answers are for linux; daily, weekly, yearly backup script this one seems close.

Would appreciate any help as it'll shave valuable minutes of my day and free up some storage.

share|improve this question

closed as not constructive by John Gardeniers, EEAA, Magellan, Ward, mdpc Nov 12 '12 at 17:44

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
No worries, I'm sure everyone here will be only too happy to waste their time if it will save a few minutes of yours. –  John Gardeniers Aug 17 '12 at 9:45
    
Hi John - I was being facetious, obviously lost on you. –  bookstorecowboy Aug 19 '12 at 16:49

1 Answer 1

The forfiles command can select files based on their ages, so something like this could be used to delete log files 7 or more days old:

forfiles /d -7 /c "cmd /c echo @file"

To save a monthly copy, use the task scheduler to copy that file to an archive folder once a month.

share|improve this answer
    
Thanks Ramruma, I've been thinking about this and I think it might be a good idea to write a little app to do it. If I do I'll post on here so people with the same problem can use it. –  bookstorecowboy Aug 19 '12 at 16:50

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