Solved

A batch to delete a folder and all its contants

Posted on 2014-03-09
9
180 Views
Last Modified: 2014-04-01
Hi Experts,

I am looking for a .bat process to delete automatically unnecessary files from a specific folder then empty the Recycle bin too.

for example :

It will check the time if its 2AM than delete the folder in C;/test
then delete the all to emptied the windows recycle bin,

I want execute the .bat in windows 7.

Thanks in advance for your prompt response.
0
Comment
Question by:alam747
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 3

Assisted Solution

by:telczj9
telczj9 earned 250 total points
Comment Utility
Alam747,

del /q /s c:\temp

Open in new window


Will delete c:\temp and all its contents without even using the recycle bin.

Cheers!
0
 
LVL 10

Expert Comment

by:Scott Thomson
Comment Utility
further to the comment above posted by " telczj9"

You could use a scheduled task to set for 2:00am

otherwise you would have this bat file running at login through startup?
- if the machine is not on at said time would you want it to start again as soon as possible??

can you explain instead of just "what you want" and give more of an example of your end goal? what you are asking for directly can certainly be done but it is also better to define the problem and have someone give you all possible solutions than give someone a request and there could be a better way.
0
 

Author Comment

by:alam747
Comment Utility
Would you please explain in detail how to do it using scheduled task as you mentioned ?
Suppose I want it to run at 2:AM and if the machine is not on said time want to start again soon as possible. -- To do that would you please explain in details where to put the above .bat and how to set it up.

Thanks
0
 
LVL 24

Expert Comment

by:lionelmm
Comment Utility
Go to scheduled tasks on control panel, depending on your operating system--which Windows do you have. Here is a you tube video that is a good place to start, to give you a basic idea http://www.youtube.com/watch?v=X7hvK5IQKAM. Note in the open advanced properties when done and then go to the setting tab and select "run as soon as possible" after schedules task is missed (win 7 and later)
Task-Schedule.jpg
0
The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

 
LVL 24

Expert Comment

by:lionelmm
Comment Utility
You can also create a a scheduled tasks using a command line, initially it is more complicated to learn but once you have one that works you can quickly and easily add others, interested? Command Line SchTasks and here are a bunch of good examples http://technet.microsoft.com/en-us/library/bb490996.aspx
0
 
LVL 10

Expert Comment

by:Scott Thomson
Comment Utility
yeah the youtube video is a great start lionelmm and with the correct oprtating system etc we can specify further exactly how to set it up although its pretty simple once you watch the video i think.

if need be i will do a step by step with screenshots for you.
0
 

Author Comment

by:alam747
Comment Utility
Hi telczj9,

I test in commnad line but its delete files under \temp but not the folders itself

would you please advise the command to delete folders and subfolder including file

Thanks
0
 
LVL 24

Accepted Solution

by:
lionelmm earned 250 total points
Comment Utility
rd c:\temp /s/q
that will delete the folder c:\temp and all it's files and folder under it.
0
 

Author Closing Comment

by:alam747
Comment Utility
thanks a lot
0

Featured Post

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now