工具或 vbscript 从多个文件中删除前 x 行?

发布于 2024-12-05 12:04:55 字数 107 浏览 0 评论 0原文

我摆弄了一些 wingrep 但似乎不支持这一点。

有没有人有幸从目录“C:\my_direc\”中的所有 .txt 文件中删除前 7 行文本?

我用的是Win XP。

I've fiddled a bit with wingrep but doesn't seem to support this.

Has anyone had any luck with say deleting the first 7 lines of text from all .txt files in directory "C:\my_direc\"?

I'm using Win XP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我太投入 2024-12-12 12:04:55

这是一个 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

Here's a VBScript solution. Haven't tested it, but it should at least put you on the right track.

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
旧街凉风 2024-12-12 12:04:55

您可以尝试删除行工具

You can try Delete Lines tool

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文