All Forums >> [Scripting] >> Post a VBScript >> Delete Line Function Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
'VBScript does not have a simple function for removing a line from a file. 'After doing a search and not finding anything decent, I wrote this function.
'Examples option explicit
'DeleteLine "c:\test.txt", "qwerty", 0, 0 'If script finds text qwerty on any line in text file c:\text.txt it will delete that line
'DeleteLine "c:\test.txt", "", 17, 0 'Script deletes line 17 in text file c:\text.txt
DeleteLine "c:\test.txt", "qwerty", 17, 0 'If script finds text qwerty on line 17 in text file c:\text.txt it will delete that line
< Message edited by TomRiddle -- 8/16/2008 8:32:32 PM >
Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You know that there is a Line property that shows you the line number right? objFile.Line Also, since this may come in useful to some....maybe add the ability have it be case-sensitive or not.
< Message edited by dm_4ever -- 8/17/2008 2:26:43 PM >