Copy this code into a notepad and save it as .vbs file and double click on it and wait for information popup to see your job getting done!!
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const ForReading=1
Const ForWriting=2
sPath = < "FolderPath" > 'Example: "C:\MyFolder"
sFindString = < "String you want to find" > 'Example: "Hero"
sReplaceString = < "String you want to replace" > 'Example: "Zero"
Set fso = CreateObject("Scripting.FileSystemObject")
set oF = fso.getfolder(sPath)
Set oFO = oF.Files
For each oFile in oFO
sFileName = oFile.name
Set objFSO = CreateObject("Scripting.FileSystemObject")
filePath = sPath &"\"& sFileName
Set myFile = objFSO.OpenTextFile(filePath, ForReading, True)
Set myTemp= objFSO.OpenTextFile(filePath &".tmp", ForWriting, True)
Do While Not myFile.AtEndofStream
myLine = myFile.ReadLine
If InStr(myLine, sFindString) Then
myLine = replace(myLine,sFindString,sReplaceString)
End If
myTemp.WriteLine myLine
Loop
myFile.Close
myTemp.Close
objFSO.DeleteFile(filePath)
objFSO.MoveFile filePath&".tmp", filePath
Set objFSO = nothing
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const ForReading=1
Const ForWriting=2
sPath = < "FolderPath" > 'Example: "C:\MyFolder"
sFindString = < "String you want to find" > 'Example: "Hero"
sReplaceString = < "String you want to replace" > 'Example: "Zero"
Set fso = CreateObject("Scripting.FileSystemObject")
set oF = fso.getfolder(sPath)
Set oFO = oF.Files
For each oFile in oFO
sFileName = oFile.name
Set objFSO = CreateObject("Scripting.FileSystemObject")
filePath = sPath &"\"& sFileName
Set myFile = objFSO.OpenTextFile(filePath, ForReading, True)
Set myTemp= objFSO.OpenTextFile(filePath &".tmp", ForWriting, True)
Do While Not myFile.AtEndofStream
myLine = myFile.ReadLine
If InStr(myLine, sFindString) Then
myLine = replace(myLine,sFindString,sReplaceString)
End If
myTemp.WriteLine myLine
Loop
myFile.Close
myTemp.Close
objFSO.DeleteFile(filePath)
objFSO.MoveFile filePath&".tmp", filePath
Set objFSO = nothing
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
No comments:
Post a Comment