Powershell 是否将multiples.txt和转换为单个文件?

Powershell 是否将multiples.txt和转换为单个文件?,powershell,batch-file,vbscript,converter,Powershell,Batch File,Vbscript,Converter,我有很多文件夹 每个文件夹中大约有1到20个.txt文件 每个.txt文件(唯一名称)都包含一个标题(第1行),后跟一个HTML格式的文本(第2行) 关于.txt内部外观的示例(1): Frankfurter tail turkey doner <p>Bacon ipsum dolor sit amet turkey sausage brisket pork.</p><p>Tongue swine turducken capicola shoulder ham

我有很多文件夹

每个文件夹中大约有1到20个.txt文件

每个.txt文件(唯一名称)都包含一个标题(第1行),后跟一个HTML格式的文本(第2行)

关于.txt内部外观的示例(1):

Frankfurter tail turkey doner
<p>Bacon ipsum dolor sit amet turkey sausage brisket pork.</p><p>Tongue swine turducken capicola shoulder hamburger pig.<p/><p>Ball tip jerky ham, doner <a href=""https://en.wikipedia.org/wiki/Meat"">filet mignon ham</a> hock bresaola jowl andouille pig cow</p>
Batman
<p>You either die a hero or you live long enough to see yourself become the villain.</p>
放在一个有十几个.txt文件的文件夹中,但控制台只是打开和关闭。没有创建文件

Edit2:现在我们在做饭

这:

给出输出:

Batman
<p>You either die a hero or you live long enough to see yourself become the villain.</p>
Frankfurter tail turkey doner
<p>Bacon ipsum dolor sit amet turkey sausage brisket pork.</p><p>Tongue swine turducken capicola shoulder hamburger pig.<p/><p>Ball tip jerky ham, doner <a href=""https://en.wikipedia.org/wiki/Meat"">filet mignon ham</a> hock bresaola jowl andouille pig cow</p>
蝙蝠侠 你要么以英雄的身份死去,要么活到足以看到自己成为恶棍的地步

法兰克福尾火鸡 培根ipsum dolor sit amet火鸡香肠胸肉。

舌头猪turducken capicola肩肉汉堡包猪。

球头肉干火腿、多纳霍克bresaola jowl和杜伊勒肉牛

这和我想要的非常接近

  • 现在添加引号并用逗号替换linebrek 这个问题没有解决
致以最良好的祝愿


吕康

得到了外部帮助,这非常有效

    @echo off
cls
setlocal
set "combined=combined.txt"
(
  for %%a in (*.txt) do (
    if not "%%a" == "%combined%" (
      echo %%a 1>&2
      set "firstLine=true"
      for /f "tokens=1,* delims=:   " %%b in ('findstr /n "^" %%a') do (
        if defined firstLine (
          set /p =""%%c",""
          set "firstLine="
        ) else if not "%%c" == "" (
          set /p =%%c
        )
      )
      echo "
    )
  )
) > %combined% <nul
endlocal
goto:eof
@echo关闭
cls
setlocal
设置“combined=combined.txt”
(
对于(*.txt)中的%%a,请执行以下操作(
如果不是“%%a”==%combined%”(
回声%%a 1>&2
设置“firstLine=true”
对于/f“tokens=1,*delims=:”%%b in('findstr/n“^”%%a')do(
如果定义为第一行(
设置/p=“%%c”
设置“firstLine=”
)否则,如果不是“%%c”==”(
设置/p=%%c
)
)
回声“
)
)

)>%combined%获得了外部帮助,这非常有效

    @echo off
cls
setlocal
set "combined=combined.txt"
(
  for %%a in (*.txt) do (
    if not "%%a" == "%combined%" (
      echo %%a 1>&2
      set "firstLine=true"
      for /f "tokens=1,* delims=:   " %%b in ('findstr /n "^" %%a') do (
        if defined firstLine (
          set /p =""%%c",""
          set "firstLine="
        ) else if not "%%c" == "" (
          set /p =%%c
        )
      )
      echo "
    )
  )
) > %combined% <nul
endlocal
goto:eof
@echo关闭
cls
setlocal
设置“combined=combined.txt”
(
对于(*.txt)中的%%a,请执行以下操作(
如果不是“%%a”==%combined%”(
回声%%a 1>&2
设置“firstLine=true”
对于/f“tokens=1,*delims=:”%%b in('findstr/n“^”%%a')do(
如果定义为第一行(
设置/p=“%%c”
设置“firstLine=”
)否则,如果不是“%%c”==”(
设置/p=%%c
)
)
回声“
)
)
)>%合并百分比
Batman
<p>You either die a hero or you live long enough to see yourself become the villain.</p>
Frankfurter tail turkey doner
<p>Bacon ipsum dolor sit amet turkey sausage brisket pork.</p><p>Tongue swine turducken capicola shoulder hamburger pig.<p/><p>Ball tip jerky ham, doner <a href=""https://en.wikipedia.org/wiki/Meat"">filet mignon ham</a> hock bresaola jowl andouille pig cow</p>
    @echo off
cls
setlocal
set "combined=combined.txt"
(
  for %%a in (*.txt) do (
    if not "%%a" == "%combined%" (
      echo %%a 1>&2
      set "firstLine=true"
      for /f "tokens=1,* delims=:   " %%b in ('findstr /n "^" %%a') do (
        if defined firstLine (
          set /p =""%%c",""
          set "firstLine="
        ) else if not "%%c" == "" (
          set /p =%%c
        )
      )
      echo "
    )
  )
) > %combined% <nul
endlocal
goto:eof