【问题标题】:Using a batch file to extract text from one file into a new one使用批处理文件将文本从一个文件提取到一个新文件中
【发布时间】:2012-02-19 07:46:21
【问题描述】:

我有一个包含 100 多个文件的文件夹,这些文件中包含文本。我正在使用这个 .bat 代码将某些文本提取到另一个文本文件中。

SETLOCAL
(FOR /L %%i IN (1,1,3) DO SET /P line=) < math.txt > lines.txt ECHO %line%
ENDLOCAL

此脚本每次仅适用于一个 .txt 文件。它不仅需要从多个文件中提取,还需要以文件到文件的顺序再次写入多个文件。完成后,我想运行另一个脚本以将提取的文本以 1 个文件到 1 个表单的顺序输入到程序表单字段中。我找到了一个脚本来操纵鼠标点击,它将运行程序,但老实说,这超出了我的专业知识。

WshShell.Sendkeys "%f" (simulates clicking "File" on the menu bar)
WshShell.Sendkeys "n" (simulates clicking the "New" option on the "File" menu)
WshShell.Sendkeys "{Enter}" (simulates clicking "OK" to finish creating a new document in Word)

【问题讨论】:

    标签: batch-file


    【解决方案1】:

    好吧,看来你需要知道 FOR 命令来选择要读取的文件(.txt),但只有

    type (insert input dir here) >> (insert ouput dir here)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-23
      • 2014-02-24
      • 2014-03-21
      • 2010-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多