As far as I can tell that will not work if the number of lines in the files exceeds 65,534. Which most of mine do.
skipline.vbs
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
ReadFileName = wscript.arguments(0)
LinesToSkip = wscript.arguments(1)
WriteFileName = wscript.arguments(2)
' for demo purposes; can delete
'--------------------------------------
StartRead = Timer
'--------------------------------------
Set ReadFile = objFSO.OpenTextFile (wscript.arguments(0), ForReading)
strText = ReadFile.ReadAll
Readfile.Close
' for demo purposes; can delete
'--------------------------------------
EndRead = Timer
ReadTime = EndRead - StartRead
StartSplit = Timer
'--------------------------------------
ArrayOfLines = Split(strText, vbCrLf)
' for demo purposes; can delete
'--------------------------------------
Endsplit = Timer
SplitTime = Endsplit - StartSplit
StartWrite = Timer
'--------------------------------------
Set Writefile = objFSO.CreateTextFile (WriteFileName, ForWriting)
For j = LinesToSkip To UBound(ArrayOfLines)
Writefile.writeline ArrayOfLines(j)
Next
Writefile.Close
' for demo purposes; can delete
'--------------------------------------
EndWrite = Timer
TotalTime = EndWrite - StartRead
WriteTime = EndWrite - StartWrite
wscript.echo "Number of Lines in file: " & UBound(ArrayOfLines)
wscript.echo "Read file in " & ReadTime & " sec(s)"
wscript.echo "Split file in " & SplitTime & " sec(s)"
wscript.echo "Wrote output file in " & WriteTime & " sec(s)"
wscript.echo "Total time taken " & TotalTime & " sec(s)"
'--------------------------------------
C:\Batch\Test\>type 20lines.txt
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
This is line 10
This is line 11
This is line 12
This is line 13
This is line 14
This is line 15
This is line 16
This is line 17
This is line 18
This is line 19
This is line 20
C:\Batch\Test\>cscript.exe //nologo skipline.vbs "20lines.txt" 3 "outlist.txt"
Number of Lines in file: 20
Read file in 0 sec(s)
Split file in 0 sec(s)
Wrote output file in 0.0078125 sec(s)
Total time taken 0.0078125 sec(s)
C:\Batch\Test\>type outlist.txt
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
This is line 10
This is line 11
This is line 12
This is line 13
This is line 14
This is line 15
This is line 16
This is line 17
This is line 18
This is line 19
This is line 20
Note: the load and split times for the small file are too short for the VBScript timer function to measure.
Now for some real files...
Clist.csv has nearly 300,000 lines like this and is 36 MB in size
"CreationTime","Length","FullName"
"04/06/2011 08:43:43","4226277376","C:\pagefile.sys"
"02/06/2011 21:08:43","3169705984","C:\hiberfil.sys"
"05/03/2011 08:14:10","2376366352","C:\Documents and Settings\Mike\X15-65732.iso"
"05/03/2011 08:14:10","2376366352","C:\Users\Mike\X15-65732.iso"
"07/07/2011 20:39:09","1818939392","C:\Users\Mike\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\Windows XP Mode.vhd"
"07/07/2011 20:39:09","1818939392","C:\Documents and Settings\Mike\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\Windows XP Mode.vhd"
C:\Batch\Test\>cscript.exe //nologo skipline.vbs "Clist.csv" 3 "outlist.txt"
Number of Lines in file: 294457
Read file in 1.953125 sec(s)
Split file in 0.6328125 sec(s)
Wrote output file in 3.632813 sec(s)
Total time taken 6.21875 sec(s)
Big-Clist.csv has nearly a million lines and is 108 MB in size
C:\Batch\Test\>cscript.exe //nologo skipline.vbs "Big-Clist.csv" 3 "outlist.txt"
Number of Lines in file: 883371
Read file in 5.164063 sec(s)
Split file in 5.390625 sec(s)
Wrote output file in 10.95313 sec(s)
Total time taken 21.50781 sec(s)
System: AMD Phenom II 3.0 GHz 4 GB RAM drive: 7200 rpm SATA