vbscript - remove specific lines and one symbol out of txt file -


hey guys have written little vbs open txt file , remove lines , \ in each line. works correctly last line of source file written multiple times destination file. last line other lines written once. wrong code? do:

option explicit dim strline  dim strnewline  dim strrawpath dim strrawpathw dim wshshell dim f dim w dim fs dim fsw dim x   x = 0  strrawpath = "c:\xampp_neu\xampp\htdocs\tc_backup\stasknoheader.txt" strrawpathw = "c:\xampp_neu\xampp\htdocs\tc_backup\stask.txt"  set wshshell = wscript.createobject("wscript.shell")  set fs = createobject("scripting.filesystemobject") set fsw = createobject("scripting.filesystemobject")          ' 2 = forwriting         set f = fs.opentextfile(strrawpath,1)         set w = fsw.opentextfile(strrawpathw,2)              while f.atendofstream <> true                 x = x+1                 redim preserve myarray(x)                 strline = f.readline                 myarray(x) = strline                   if instr(strline, "microsoft") = 0                     if instr(strline, "taskname") = 0                         if instr(strline, "restart system") = 0                             ifinstr(strline,"schedulerhsmmigtc11tdrive") = 0                           strnewline = strline                         strnewline =(replace(strline,"\","",1,1))                             end if                         end if                     end if                 end if                                    w.write strnewline & vbcrlf              loop           f.close         w.close 

you need move w.write strnewline & vbcrlf inside if statetment, after strnewline =(replace(strline,"\","",1,1)) string.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -