Automation File Delete

Posted on 2011-03-11
Last Modified: 2012-06-27
I need an automated routine that will fire at midnight and delete every file in a specific folder.

Can someone point me at the right application?

.bat file?
Question by:webdork
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2

Expert Comment

ID: 35112722
batch files are a good starting point.  The open source program xdel offers quite a bit of extended functionality on delete operations as well.

Expert Comment

ID: 35112728
Oh and you'll want to use Scheduled Tasks to execute the batch file (even while a user is logged off, make SURE you end up entering a username and password).
LVL 56

Expert Comment

by:Bill Prew
ID: 35113183
Yes, a BAT file could be a good solution to this.  It could be as simple as:

@echo off
del /Q "c:\temp\*.*"

Open in new window

if you wanted to remove all files in the c:\temp folder.  If you need more elaborate criteria for the deletion like file size or age, then you may want to look at a more advanced script language like VB Script or PowerShell.  Or look at some of the free utilities that exist and support that.  I won't share any unless you come back with needs that require them.

Once you vreate the BAT file you can schedule it with the Windows task scheduler, take a look at this tutorial.

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.


Author Comment

ID: 35113212
Thanks billprew-- seems simple enough. What is the Q switch?
LVL 56

Accepted Solution

Bill Prew earned 500 total points
ID: 35113657
The /Q is for "quiet mode", which tells the DEL command not to prompt for confirmation when deleting multiple files via wildcard.

You can always get a summary of command switches by doing the command followed by a /?, kike:

DEL /?


Author Closing Comment

ID: 35117787
Thank you. Simple is good...

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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