PDA

View Full Version : Batch File Help


agita
08-08-2007, 02:14 PM
Hello this is my first post, don't want to irritate so i'll jump to the point.

I'm looking for some help with creating a batch file.

I want to delete multiple files, but just to keep it simple i will say one.

If i want to delete my temp files from the temp folder in windows ie.

C:\WINDOWS\Temp\

How do I delete everything in the folder but not the folder itself?


EDIT:

Answered my own question

del /s C:\WINDOWS\Temp\*

I kept deleting the entire folder lol.

Omega
09-03-2007, 04:21 PM
Yup. Alternatively, if you wanted a more 'scripty' way to accomplish it, you could:
for %i in (c:\WINDOWS\Temp\*) do del %i

As a side note, I like to test scripts like this prior to actually running them, by doing something along the lines of:
for %i in (c:\WINDOWS\Temp\*) do echo %i