Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
HI all
I have a system which creates log files twice a day, however doesnt delete old ones. Rather than delete them myself and as they are quite large I want them to be deleted automatically by a BAT fle on a scheduled task.
The files have a naming convention aswell of [DATE][Time]log.txt e.g. 20040617200000log.txt
I cant think of a code to evaluate which files are greater than 5 days old. Can anyone help?
Many Thanks
Tim

Hi Tim,
Not obvious how to do it with a BAT.
Why don't you just go to the folder, sort newest to oldest, single click the neweat you want rid of then:
shift-end
del
enterOnce you get the hang of it, it takes less than 5 seconds.
HTH
M2

Hello Tim,
This is a bit of a cludge, but I did implement it on a client's box, and it's worked fine (automatically)for a couple of years:
The trick is to make the batch a wrapper for the backup prog...
Create a directory to hold your backups with five sub-directories.
The batch runs before the prog, renames directory #5 to #6, #4 to #5, #3 to #4, etc... ending with md #1.
Then the batch calls the prog, and after, if the backup file cannot be directed to your dir structure, the batch can snag it and move it there (to #1).
If all goes well, and no errors, then delete Dir #6. (this could also be done w/ copy or move on the files as well)I know this isn't exactly what you are looking for, and this is a fairly loose description- I just tried to get the basic concept out there.
Hope it helps.
Bruce

hi, at http://plop.at under downloads there is an example how to delete files older than some days
3 files needed for that datetime.com, lsfdt.com and delflist.com, those files are there too

Hi
I written a batch file to do this in WinXP.
Doe's your NT support this syntax if so it might work.ie set /a x=1+2
for /f %%a in (Filenane) do call :Label %%a
if %Var% GTR 4
and also multline statements using brackets
if %Today%==Tue (
set Tomorrow=Wed
)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |