Displaying  Source Code(s)  
 

 
Find And Delete

--------------------------------------------------------------------------------

Description : This searches through each file in a folder with .htm, .html, and .asp extensions and searches for a string. If the string is found it is replaces with a blank or can be modified to replace with another string.

****** FindAndDelete.vbs ************

Const ForReading = 1
Const ForWriting = 2

Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("d:inetpubwwwroot")
Set files = folder.files

varText = "Script that you want to delete"

For Each f1 In files
If InStr(f1,".asp") > 0 Or InStr(f1,".htm") > 0 Or InStr(f1,".html") > 0
Then
Set f = fso.OpenTextFile(f1,ForReading)
If Not f.AtEndOfStream Then
varNew = Replace(f.ReadAll,varText,"")
Set f = fso.OpenTextFile(f1,ForWriting )
f.Write varNew
End If
Set f = Nothing
End If
Next

MsgBox "Change OK"

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG