标题: 怎么批量将文档名称放入文档内 50元微信或支付宝 [打印本页]
作者: 师宇 时间: 2022-4-3 10:34 标题: 怎么批量将文档名称放入文档内 50元微信或支付宝
文件夹内文档名称放在文档第一行,文字字体为宋体四号
照片链接:https://pan.baidu.com/s/1-Seoep9qwKrppS1Y8l8BlQ
提取码:08qm
作者: zaqmlp 时间: 2022-4-3 11:39
需安装有Microsoft Office
以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行- /*&cls&echo off&cd /d "%~dp0"
- type "%~f0"|cscript -nologo -e:jscript "%~f0">"%tmp%\v.v"
- dir /a-d-h/b|findstr /ie "\.doc \.docx"|cscript -nologo -e:vbscript "%tmp%\v.v"
- pause
- exit
- */
- var text=WSH.StdIn.ReadAll();
- var vbs=text.match(/\/\*\r\n([\s\S]+)\*\/\s*$/);
- WSH.echo(vbs[1]);
- /*
- On Error Resume Next
- Set fso=CreateObject("Scripting.Filesystemobject")
- Set word=CreateObject("Word.Application")
-
- If Err.Number <>0 Then
- WSH.StdErr.WriteLine "Microsoft Word 未安装"
- WSH.Quit
- End If
- On Error Goto 0
- word.DisplayAlerts=False
- word.Visible=True
-
-
- Do While WSH.StdIn.AtEndOfStream<>True
- On Error Resume Next
- it=WSH.StdIn.ReadLine
- basename=fso.GetBaseName(it)
- Set docfile=fso.GetFile(it)
- If Left(docfile.shortname, 2) <> "~$" Then
- Set doc=word.Documents.Open(docfile.Path,,,,"pwd")
- If doc Is Nothing Then
- doc.Close
- End If
- doc.Activate
- doc.Range(0).Select
- word.Selection.HomeKey 6
- word.Selection.Font.Name="宋体"
- word.Selection.Font.Size=14
- word.Selection.TypeText basename
- word.Selection.TypeParagraph
- word.Selection.TypeParagraph
- doc.Close True
- WSH.echo "[Done]" &it
- End If
- If Err.Number <>0 Then
- WSH.StdErr.WriteLine "[Error]" &it
- End If
- On Error Goto 0
- Loop
-
- word.Quit
- WSH.Quit
- */
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |