使用批处理文件将文本从一个文件中提取到一个新文件中

时间:2012-02-19 07:46:21

标签: batch-file

我有一个包含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)

1 个答案:

答案 0 :(得分:0)

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

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