i need help with this VBScript
What I'm trying to do here is modify the logfile to remove the extra spaces inside. (I just got this script actually somewhere on the net.)
It works if i specify just a single file but I'm trying to modify multiple files. Using the wildcard character as i did below did not work either (sorry I'm not so good with vbs)
Also does anyone know how we can do this without creating a new output file? just modify the original file. Thanks in advance..
Set objFSO = CreateObject("Scripting.FileSystemObject")
'change this line to wherever you want to read the input from.
Set objTextFile = objFSO.OpenTextFile("D:\access*.log",1)
Set objNewFile = objFSO.CreateTextFile("D:\access*_new.log")
Do Until objTextFile.AtEndOfStream
myString = objTextFile.Readline
objNewFile.WriteLine(Replace (myString, " ", " "))
Loop
" "by spaces" ", this will result in the same output as the input. You can replace double spaces by single spaces, but you'll still end up with double spaces if there are triple spaces... Ideally you would use a regular expression replace. 2. If you want to modify a file without creating another you have to buffer your input, and overwrite the file with the buffer (this is risky, you could lose data), maybe you could do it with ADO. 3. You cannot use wildcards, you should specify a folder, iterate over all files and pick the ones matching a specific name.