Delete a set of files on a particular system date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pkmadhusudhan
Posts: 1
Joined: 22 Feb 2014 03:01

Delete a set of files on a particular system date

#1 Post by pkmadhusudhan » 22 Feb 2014 03:06

we have few excel and word documents in a folder and that needs to be deleted on a particular date automatically and regularly.
These excel files are temporarily exported from our accounting software .
For eg. we need to delete files in BACKUP folder in c:\ on system date turning 1st. If it misses the cycle, it should delete next month 1st.
Thanks in advance

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Delete a set of files on a particular system date

#2 Post by foxidrive » 22 Feb 2014 05:44

Task Scheduler will run a batch file on the 1st every month.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Delete a set of files on a particular system date

#3 Post by Samir » 27 Feb 2014 10:49

I use this code to do a time match. I'm sure the same logic could be used with %DATE% to check the date or day:

Code: Select all

:START
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Delete a set of files on a particular system date

#4 Post by Squashman » 27 Feb 2014 11:27

Samir wrote:I use this code to do a time match. I'm sure the same logic could be used with %DATE% to check the date or day:

Code: Select all

:START
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

But you would still have to then run the batch file every day. If you just have Windows Task Scheduler run it on the 1st day of the month then there is no need to check the date.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Delete a set of files on a particular system date

#5 Post by Samir » 27 Mar 2014 08:19

Squashman wrote:
Samir wrote:I use this code to do a time match. I'm sure the same logic could be used with %DATE% to check the date or day:

Code: Select all

:START
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

But you would still have to then run the batch file every day. If you just have Windows Task Scheduler run it on the 1st day of the month then there is no need to check the date.
True, but I trust a batch file to autostart more than I trust windows task scheduler.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Delete a set of files on a particular system date

#6 Post by Squashman » 27 Mar 2014 08:30

Samir wrote:
Squashman wrote:
Samir wrote:I use this code to do a time match. I'm sure the same logic could be used with %DATE% to check the date or day:

Code: Select all

:START
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

But you would still have to then run the batch file every day. If you just have Windows Task Scheduler run it on the 1st day of the month then there is no need to check the date.
True, but I trust a batch file to autostart more than I trust windows task scheduler.

Well I will disagree with you all day and all night on that point. I do Automation for a Living. We have over 600 automated tasks that run every day. I would say about 100 of these are triggered by Task Scheduler every day. All these tasks are spread out over 3 application servers. Hasn't failed us yet.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Delete a set of files on a particular system date

#7 Post by Samir » 19 Jun 2014 17:41

Squashman wrote:Well I will disagree with you all day and all night on that point. I do Automation for a Living. We have over 600 automated tasks that run every day. I would say about 100 of these are triggered by Task Scheduler every day. All these tasks are spread out over 3 application servers. Hasn't failed us yet.
Your luck has been better than mine. If something crashes the kernel or task scheduler, it's hosed in my case. So I just trust a simple batch file to do it as they usually survive such problems. 8)

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Delete a set of files on a particular system date

#8 Post by Squashman » 19 Jun 2014 18:28

Samir wrote:
Squashman wrote:Well I will disagree with you all day and all night on that point. I do Automation for a Living. We have over 600 automated tasks that run every day. I would say about 100 of these are triggered by Task Scheduler every day. All these tasks are spread out over 3 application servers. Hasn't failed us yet.
Your luck has been better than mine. If something crashes the kernel or task scheduler, it's hosed in my case. So I just trust a simple batch file to do it as they usually survive such problems. 8)

The stuff I have been managing has been running for 5 years without a hitch. Task Scheduler has never failed us.

Even in my Unix days, CRON never failed me.

I would rather not have a batch file constantly running and checking something. On a Windows Vista and above, every time you start a batch file it launches two processes. CMD.exe and Conhost.exe. If I did that with all my batch files I would have over 200 processes running.

Post Reply