找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 20230|回复: 5

[文件操作] pdftk批处理怎样合并不同目录下的PDF文件?

[复制链接]
发表于 2023-8-8 08:11:26 | 显示全部楼层 |阅读模式
各位高手,我要实现自动PDF合并功能,需要用到pdftk的批处理,假定现在我有三个PDF文件需要合并,分别在不同目录下面,A.pdf在C:\Users\reche\Desktop\test\公共 路径下,B.pdf在C:\Users\reche\Desktop\test\生成 路径下,C.pdf在C:\Users\reche\Desktop\test\概算 路径下,合并后的文件名为D..pdf放在C:\Users\reche\Desktop\test\合并PDF 路径下。请高手帮忙修改一下下面的批处理语句,谢谢!
  1. @echo off
  2. cd "C:\Users\reche\Desktop\test"
  3. pdftk "C:\Users\reche\Desktop\test\公共\A.pdf" "C:\Users\reche\Desktop\test\生成\B.pdf" "C:\Users\reche\Desktop\test\概算\C.pdf" cat output "C:\Users\reche\Desktop\test\合成PDF\D.pdf"
复制代码
发表于 2023-8-8 13:13:12 | 显示全部楼层
看不懂,你的批处理不行么?还有改成啥?
 楼主| 发表于 2023-8-8 14:20:22 | 显示全部楼层
回复 2# Five66

是的,批处理不行
发表于 2023-8-8 14:33:47 | 显示全部楼层
本帖最后由 77七 于 2023-8-8 15:08 编辑
D..pdf放在C:\Users\reche\Desktop\test\合PDF 路径下
pdftk "C:\Users\reche\Desktop\test\公共\A.pdf" "C:\Users\reche\Desktop\test\生成\B.pdf" "C:\Users\reche\Desktop\test\概算\C.pdf" cat output "C:\Users\reche\Desktop\test\合PDF\D.pdf"

是否有笔误?
另外,把批处理保存为ansi编码格式。
如果pdftk.exe在test目录下,批处理文件不在c盘,需要使用cd /d 切换目录。
发表于 2023-8-8 15:12:35 | 显示全部楼层
回复 3# recheazeng

在原来批处理后面加上一行pause,再次运行看有啥提示
发表于 2023-8-9 15:14:42 | 显示全部楼层
回复 1# recheazeng


请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA
  1. @echo off
  2. REM 1、下载并安装 PDFtk 这个命令行工具
  3. REM http://bcn.bathome.net/s/tool/index.html?key=PDFtk
  4. REM 2、根据自己电脑实际安装路径设置以下临时环境变量
  5. set "path=C:\Program Files (x86)\PDFtk Server\bin;%path%"

  6. set "NewFolder=C:\Users\reche\Desktop\test\合并PDF"
  7. if not exist "%NewFolder%" (
  8.     md "%NewFolder%"
  9. )
  10. pdftk.exe "C:\Users\reche\Desktop\test\公共\A.pdf" "C:\Users\reche\Desktop\test\生成\B.pdf" "C:\Users\reche\Desktop\test\概算\C.pdf" cat output "%NewFolder%\D.pdf"
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-18 14:32 , Processed in 0.018769 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表