使用批处理文件使用for循环查找和替换文件夹中的文本文件

时间:2018-01-23 14:51:08

标签: batch-file for-loop replace find

我有30个文件夹(Folder1,Folder2 ... Folder30),文件夹中有txt文件。 (Text1.Txt,Text2.Txt)

我想这样做;

复制并合并text1.txt和text2.txt文件的第一行,并将其写入text1.txt文件。

我想用for循环来做这件事。

这是我的代码

FOR /L %%A IN (0,1,30) DO (
set /p texte=< D:\proc\folder%%A\Text1.txt
set /p textf=< D:\proc\folder%%A\Text2.txt 
powershell -Command "(gc D:\proc\folder%%A\Text1.txt) -replace '%texte%', '%texte% %textf%' "
(

0 个答案:

没有答案