Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

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
0
humer2000
Asked:
humer2000
  • 2
  • 2
1 Solution
 
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
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now