Discussion Locked

Batch File - delete tmp files

0 helpful
16 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello,
I am not familiar with batch files, so I post this question:
I would like to create a batch file which deletes all the temporary files that are older than a week (not only the files in the TEMP folder, all the tmp files) on the computers ofthe domain.
Thanks

16 replies

by opatzg9

Simple batch instructions cannot give you date logic on file detail, you would need a program to do that. Most any language should be capable and easy enough to write.

by matt_s

We schedule the windows disk cleanup utility to run, which removes tmp files.

by jna

I tried that on windows 2000, but i do not see this tool on windows nt. It's not really a problem since we are soon moving to 2k, but is there a way to centralize this cleanup so that the admin runs it when he wants for all the computers ? (Sorry i did not really have time to look at it)

by cactus pete

You can use some creative writing to get batch files to figure out dates...but the program gets longer than it really needs to be. If you really want to see how to do date differences in the DOS command language, check out the dos batch newsgroups.

If you aren't against using VB Script, I'd recommend that route. You can use the built in datediff function.

Otherwise, go with Matt_S.

by cglrcng9

Follow the link to Langa.com below, pick the batch file you wish & open it and edit it accordingly. There are like 15 different batch files avail. there, I use them as is and have never had 1 single problem w/ any of them.

http://www.langa.com/cleanup_bat.htm

Good Luck.

by jna

Yes, thanks, it seems really interesting, i will try it as soon as i can (i'm very busy these days) and close the question if it works

by curious_george

Depends on the OS(es) you are targeting, the command interpreter is different on all MS OSes. Send me an email to dstewart@luv2frag.com with the OS version you are using and I will write it for you, its pretty simple.

You mention a domain so the probablility is high that you mean NT4, W2K, and/or XP. The Win9x Command interpreter is very limited comparatively.

by cglrcng9

I assume from the mail that was just what you were looking for.

Cheers mate! And TY.

This discussion is closed to new replies.