June 24, 2008 at 9:22 am
Hello everyone,
i am trying to create a batch file that will delete files that are older that 24 hours
what would be the dos command that i can put in that .bat file
thanks
June 24, 2008 at 9:38 am
I don't think a batch file can do that. I could be wrong, but del doesn't seem to have a property that will read file date, just name and extension. There are other solutions, depending on what type of files you are trying to get rid of. If it's backup files, a maintenance plan with a cleanup action can do it, for example.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 24, 2008 at 9:40 am
There are some really useful examples of Batch files on this site;
http://www.chebucto.ns.ca/~ak621/DOS/Bat-Adv.html">
http://www.chebucto.ns.ca/~ak621/DOS/Bat-Adv.html
They should have what you are after or something close that you can modify.
As this is a SQL forum, why don't you use a maintenance plan to do the delete?
June 24, 2008 at 9:43 am
GSquared (6/24/2008)
I don't think a batch file can do that. I could be wrong, but del doesn't seem to have a property that will read file date, just name and extension. There are other solutions, depending on what type of files you are trying to get rid of. If it's backup files, a maintenance plan with a cleanup action can do it, for example.
It can be done, but involves looping through the file names based upon the create/modify date and deleting based upon that.
Much easier to use a maintenance plan though.
June 24, 2008 at 10:04 am
here is the story:
i am doing full backup to disk, daily
then Data Guard backup software does the backup to tape for those .bak files
it has an option, on success start the .bat or .exe file
this where i want this .bat file to delete all backups that older then 24 hours
but the whole purpose is to make sure that archiving to tape had ran successfully
June 24, 2008 at 11:03 am
Well, you could install Powershell, write a Powershell script to do it (which I am told is comparatively easy), then call the Powershell script from your .BAT file.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 24, 2008 at 12:17 pm
thanks !!!!!!!!
June 24, 2008 at 12:27 pm
Let us know how it works out. 🙂
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply