How to batch detele specific files in specific folders

Hi Experts
I want to delete .log files in log folders
There is hundreds of log folders located under hundred different directories but all located at c:\
ie :
c:\inetpub\wwwroot\Site1\site1\log\wmloe\*.log
c:\inetpub\wwwroot\Site2\site2\log\w3poose\*.log
c:\inetpub\wwwroot\Site3\site3\log\wdrrmop\*.log
etc...

How to delete all my log files at once ?
thx
LVL 1
humer2000Asked:
Who is Participating?
 
SteveGTRCommented:
To delete all log files from the c: drive you could do this:

del /s /f *.log

This will work equally well from a base directory:

del /s /f c:\inetpub\*.log
0
 
merowingerCommented:
start->search->
search files and folder in "c:\inetpub\wwwroot\"
filename: *.log
After search ended -> STRG-A -> DEL
0
 
humer2000Author Commented:
no i cant use this solution, i already tried.
this solution crahes my server, because log files are hudge enough to take all available memory
i need another solution
thx
0
 
merowingerCommented:
other option vbscript:

dim objFSO
set objFSO=CreateObject("Scripting.FileSystemObject")

folder1=objFSO.GetFolder("c:\inetpub\wwwroot\Site1\site1\log\wmloe")
folder2=objFSO.GetFolder("c:\inetpub\wwwroot\Site2\site2\log\w3poose")
folder3=objFSO.GetFolder("c:\inetpub\wwwroot\Site3\site3\log\wdrrmop")

for each file in folder1
If Right(objFSO.GetFileName(File), 3) = "log" Then
objFSO.DeleteFile(file)
end if
next

for each file in folder2
If Right(objFSO.GetFileName(File), 3) = "log" Then
objFSO.DeleteFile(file)
end if
next

for each file in folder3
If Right(objFSO.GetFileName(File), 3) = "log" Then
objFSO.DeleteFile(file)
end if
next
0
 
humer2000Author Commented:
may be u did not read  the question carefully
there hundreds of directories, maybe more.
i need a BATCH delete procedure.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.