1.

Solve : batch file to delete temp files?

Answer»

Hi Frdz,

I am familar with some basic Dos commands and i am trying to MAKE a batch file to delete temp files, like in dos if w'll give this command
c:\>del *. tmp /s and it works But it is not working in batch file...!

Can any one help me out PLZDon't put the c:\> at the beginning.
Try this:
Code: [Select]cd c:\
del *.tmp /q /f /sI'm not sure you need the 'cd c:\' though.Quote

Code: [Select]cd c:\
del *.tmp /q /f /sI'm not sure you need the 'cd c:\' though.
that's not really accurate. you don't change to c drive like that. no need to put "cd".
just c: will do.
anyway, @OP, don't just say it does not work. try to give error messages if you have them, or describe in more detail what you did not see expected.Simple cookie kill batch

cls
REM *******************************************
REM **Cookie Kill Program Will not work in NT**
REM *******************************************

deltree /y c:\windows\cookies\*.*
deltree /y c:\windows\tempor~1\*.*
pause
cls
REM Cookies deleted!

=========================================================

This version is a little more thurough, deletes alot of junk

cls
@ECHO OFF
ECHO. ***********************************
ECHO. ** Clean Cookies and Temp Files **
ECHO. ** Will not work in NT **
ECHO. *******************************
deltree /y c:\windows\cookies\*.*
deltree /y c:\windows\tempor~1\*.*
deltree /y c:\progra~1\Netscape\Users\default\Cache\*.jpg
deltree /y c:\progra~1\Netscape\Users\default\Cache\*.gif
deltree /y c:\progra~1\Netscape\Users\default\Cache\*.htm
deltree /y c:\progra~1\Netscape\Users\default\archive\*.htm
deltree /y c:\progra~1\Netscape\Users\default\archive\*.gif
deltree /y c:\progra~1\Netscape\Users\default\archive\*.jpg
deltree /y c:\windows\temp\*.*
deltree /y c:\temp\*.*
deltree /y c:\windows\Recent\*.*
deltree /y c:\recycled\*.*
cls
EXIT

========================================================

WINNT Version

@ECHO OFF
ECHO **************************************************
ECHO ** DEL replaces DELTREE, /Q replaces /Y **
ECHO **************************************************

del /Q c:\docume~1\alluse~1\Cookies\*.*
REM Change alluse~1 in the above line to your userID
del /q c:\winnt\temp\*.*
del /q c:\temp\*.*
del /q c:\winnt\Recent\*.*
del /q c:\*.chk
EXIT

Add these lines for XP
del /q C:\Windows\Temp\Adware\*.*
del /q C:\Windows\Temp\History\*.*
del /q C:\Windows\Temp\Tempor~1\*.*
del /q C:\Windows\Temp\Cookies\*.*

=====================================================
More can be found here: http://home.att.net/~gobruen/progs/dos_batch/dos_batch.html

Hope this helps
-Linux711 Hi,
by giving this commands it works
@ECHO OFF
del /q C:\Windows\Temp\*.*
Pause
exit

Yes it does! I don't have any problem deleting the temp files from Windows\temp

What about deleting the sub dirs under your D:\Documents and Settings\$username%\Local Settings\Temp?

How do you do that?

Any ideas? Quote from: raj_1107 on April 17, 2007, 01:11:42 AM

What about deleting the sub dirs under your D:\Documents and Settings\$username%\Local Settings\Temp?

How do you do that?

Any ideas?

Through batch

del %temp%\*.tmp/s
pause
Quote
What about deleting the sub dirs under your D:\Documents and Settings\$username%\Local Settings\Temp?
How do you do that?
Any ideas?

the del command has a /S option for recursively going into subdirectories.yeah, if you use del PATH /s, it deletes sub directories too.

EDIT: Oh SORRY, i somehow thought the quote was the question ...


Discussion

No Comment Found