2011-09-20 59 views

回答

2

這是VBScript解決方案。還沒有測試過,但它至少應該把你放在正確的軌道上。

Dim FSO, txs, fld, fil, content, nLinesToSkip, i 
Set FSO = CreateObject("Scripting.FileSystemObject") 

nLinesToSkip = 7 

fld = FSO.GetFolder("C:\test\") 
For Each fil In fld 
    If Right(fil.Name, 3) = "txt" Then 

     Set txs = fil.OpenAsTextStream(1) ' 1 = for reading 
     For i = 1 To nLinesToSkip 
      txs.SkipLine 
     Next i 
     content = txs.ReadAll 
     txs.Close 

     Set txs = fil.OpenAsTextStream(2) ' 2 = for writing 
     txs.Write content 
     txs.Close 

    End If 
Next fil