Looking for basic script to delete files older than 14 days

With a minimum complexity, which will be able to run as a scheduled task.
I've found this one:
http://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09/view/Discussions#content

which looks good, but maybe a bit of an overkill to the basic functionality which we need; only delete all files in a specific network share which are older than 14 days (or any given number of days).

Thanks
IT_Group1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alan HardistyCo-OwnerCommented:
Try the following which I use on several customers computers:

FORFILES /p "x:\path" /m *.txt /d -14 /c "CMD /C del /Q @FILE"

This will delete files older that 14 days in x:\path for *.txt files

You can amend the path and the file types accordingly and the -14 is the variable for files older than to get rid of.

You can put it in a batch file, then schedule the task and it will keep the folder tidy permanently.

Alan
0
reitznerCommented:
Try to search for a little tool called 'delage' - it is freeware and works!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

IT_Group1Author Commented:
Amazing tool. Thanks bro
0
Alan HardistyCo-OwnerCommented:
Did you try any of the other proposed solutions?
0
IT_Group1Author Commented:
Nope, the tool did the job well
0
Alan HardistyCo-OwnerCommented:
Great - remind me to not bother helping you in future.

Alan
0
IT_Group1Author Commented:
Alan, that's not the way to go.
We've looked for an EASY way, preferably a tool which does the deletion.
Please don't take it personally.
0
Alan HardistyCo-OwnerCommented:
My command in batch file setup to run automatically on a regular basis works just as well - I use it on a dozen computers we support.
0
IT_Group1Author Commented:
I'm sure, again nothing personal
0
Alan HardistyCo-OwnerCommented:
I'm sure its nothing personal, but what you are doing by ignoring the people who post first and then awarding points to a solution posted afterwards without even giving an assisted solution to the other posts means that the Experts whose posts you ignore, may well ignore you in the future, which won't help you long term.

You asked for a simple script - which I gave you.

The accepted post wasn't even posted the same day, so you seem to have just started at the bottom of the post, found that it worked and closed the question.  You even acknowledge that you didn't even try the other solutions - hence why should I bother helping you in the future, when you completely ignore my help, which I know works and answers your question.

If you had split the points, having tried the solutions and decided which one was better, then I wouldn't be commenting.

Alan
0
IT_Group1Author Commented:
Agreed,
I've asked to re-open the question and split the points.

Thank you for bringing this issue to my attention.
0
Alan HardistyCo-OwnerCommented:
Thank you - I'm not worried about the points - as you can see I have quite a few, it is more a case of politeness and etiquette that I'm trying to convey, hopefully in a non-aggressive way.

It will help you in the future if you work from the top down in a question and ideally try all the proposed solutions (assuming you get more than one).  If one works and the others don't then awarding all the points to the one that works is a perfectly valid way to close the question.

If several work and you prefer one more than the other, then a split is a perfectly acceptable way to close the question with the 'Best' answer being awarded the lions share of the points, or a 50/50 split - it's your call as they are your points.

Best wishes

Alan
0
IT_Group1Author Commented:
Alan, again - I couldn't agree more.
Thanks for the effort !

BR
Nir
0
Alan HardistyCo-OwnerCommented:
You are welcome.

See you in another question sometime!!

Alan
0
IT_Group1Author Commented:
Thank you all guys.
Nir
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.