Computing.Net > Forums > Disk Operating System > BAT file to del file > 5days

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

BAT file to del file > 5days

Reply to Message Icon

Name: TimJR
Date: June 17, 2004 at 02:55:27 Pacific
OS: NT
CPU/Ram: 512
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 17, 2004 at 07:23:29 Pacific
Reply:

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
enter

Once you get the hang of it, it takes less than 5 seconds.

HTH

M2


0

Response Number 2
Name: roamer_1
Date: June 17, 2004 at 20:27:47 Pacific
Reply:

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



0

Response Number 3
Name: bitbyte
Date: June 19, 2004 at 08:15:59 Pacific
Reply:

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


0

Response Number 4
Name: dtech10
Date: June 24, 2004 at 18:26:06 Pacific
Reply:

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
)



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: BAT file to del file > 5days

if/then in bat file www.computing.net/answers/dos/ifthen-in-bat-file/13907.html

Bat file - print dir name to filenm www.computing.net/answers/dos/bat-file-print-dir-name-to-filenm/14147.html

Pass Parms to Bat file www.computing.net/answers/dos/pass-parms-to-bat-file/12072.html