标题: [文本处理] 求助:bat如何批量删除多个word文档里的分页符 [打印本页]
作者: 453765918 时间: 2023-10-20 14:06 标题: 求助:bat如何批量删除多个word文档里的分页符
bat如何批量删除多个word文档里的分页符
作者: Five66 时间: 2023-10-21 05:09
你看下面这个行不?
https://www.cnblogs.com/sharer/p/17538327.html
作者: Batcher 时间: 2023-10-21 11:56
回复 1# 453765918
test.bat- # & cls & @cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression " & exit /b
- # 设置待处理的文件所在的文件夹路径
- $OldFolder = "C:\Test\From"
- # 处理之后的文件保存到新的文件夹路径
- $NewFolder = "C:\Test\To"
- $Word = New-Object -ComObject Word.Application
- Get-ChildItem -Path $OldFolder "*.docx" | ForEach-Object {
- $_.FullName
- $NewName = $NewFolder + "\" + $_.Name
- $Doc = $Word.Documents.Open($_.FullName)
- $Select = $Word.Selection
- $Select.WholeStory()
- $OldStr = "^m"
- $NewStr = ""
- $Select.Find.Execute($OldStr, $false, $true, $false, $false, $false, $true, $false, $false, $NewStr)
- $Doc.SaveAs($NewName)
- $Doc.Close()
- }
- $word.Quit()
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |