返回列表 发帖
处理一下特殊字符吧
  1. @echo off
  2. set/p w=<%~fs0 >nul
  3. set "s=★★★★★"
  4. setlocal enabledelayedexpansion
  5. for /f "tokens=*" %%i in (1.txt) do (
  6.     set "str=%%~i"
  7.     if "!str:~,5!" == "!s!" (
  8.        set "file=!str:*%s%=!.txt"
  9.        set "filename="
  10.        call :loop "!file!"
  11.     ) else if defined filename (>>"!filename!" echo;!str!)
  12. )
  13. pause & exit
  14. :loop
  15. for /f tokens^=1*delims^=:\/*?^<^>^" %%a in ("%~1") do (
  16.      set filename=!filename!%%a
  17.      call :loop "%%b"
  18. )
  19. exit /b
复制代码

TOP

powershell 直接从word文档导出txt 这里档名为 a.docx
  1. <# : batch portion (begins PowerShell multi-line comment block)
  2. @echo off & setlocal
  3. powershell -noprofile -NoLogo "iex (${%~f0} | out-string)"
  4. pause
  5. exit
  6. #>
  7. $word = New-Object -ComObject Word.Application
  8. $file = (ls a.docx).FullName
  9. $doc = $word.Documents.Open($file)
  10. $text = $doc.Content.Text
  11. $pattern =[regex] '(?i)(Module\d+\s+unit\d+)[\r\n]*(.+?)(?=Module\d+\s+unit\d+|$)'
  12. $paragraphs = [regex]::matches($text,$pattern)
  13. $doc.Close()
  14. $word.Quit()
  15. $paragraphs.ForEach({[IO.File]::WriteAllText( $_.Groups[1].Value+ '.txt',$_.Groups[2].Value,[Text.Encoding]::Default)})
复制代码

TOP

返回列表