Solved

A batch to delete a folder and all its contants

Posted on 2014-03-09
9
185 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
[X]
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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 3

Assisted Solution

by:telczj9
telczj9 earned 250 total points
ID: 39916749
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
ID: 39916778
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
ID: 39917144
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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 25

Expert Comment

by:Lionel MM
ID: 39917553
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
 
LVL 25

Expert Comment

by:Lionel MM
ID: 39917561
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
ID: 39919512
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
ID: 39933508
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 25

Accepted Solution

by:
Lionel MM earned 250 total points
ID: 39934017
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
ID: 39970995
thanks a lot
0

Featured Post

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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