Batch File

]SK[

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
302
Anyone think this is possible?

I want to delete all *.ztmp files. Can I make the batch search though subfolders and delete any .ztmp files it finds?

Last resort would be to add each subfolder, which will take a long time :(
 

sibanac

Fledgling Freddie
Joined
Dec 19, 2003
Messages
824
on unix :

Code:
find / -name \*.ztmp  -ok rm {} \;

on windows i havent got any idee except using the search and then deleting all the results manualy
 

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
Del x:\*.ztmp /s (/p if you want a y/n prompt), obviously replacing x for whichever drive you want.
 

]SK[

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
302
Is there a way to output the deleted info into a txt file as well as onscreen?

The batch is this atm...

Code:
@ECHO OFF
Echo *  This little batch file will clean out	*
Echo *  temporary ztmp files created from clients	*
Echo *  downloading maps off the server.		*
Echo *  If you do not wish to continue close		*
Echo *  this window.					*
Echo *  This script is written thinking your HLDS	*
Echo *  installation is installed in c:\hlserver		*
Echo -
pause
cd c:\
cd hlserver
Echo Deleting ztmp files...
Echo -
del *.ztmp /s
Echo -
Echo OK All clean!
pause
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
Yes :)

Add the following to the del command:
Code:
del *.ztmp /s > X:\path\to\output.log

Just make sure that the script is flawless first, since any prompts will also get redirected into the log file.

If you want the same log file to have the data appended (rather than a new log file every time - you could for instance make a dynamic name using DATE or something) then replace with something like this:
Code:
echo >> output.log
date /t >> output.log
del *.ztmp /s >> output.log

Note the ">>" rather than ">". The ">>" means "Append" rather than writing a new file.

I hope that works for you :)
 

]SK[

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
302
Ah I did do it right but I was looking in the wrong place :eek:

Is there a way to make the log appear in the same place as where the batch is?
 

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
Just specify the path before the log file name.

e.g. if .bat is in c:\files\temp\ then del *.ztmp /s >> c:\files\temp\output.log
 

]SK[

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
302
Yeah but I meant if the batch file moved from a directory, without having to type the path in again?
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
It should work if you just specify ".\output.log" as the log file and specify the full path for the del command. Then just run the script and it should appear alongside the script file.
 

Users who are viewing this thread

Top Bottom