You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用pdftk批量拆分多PDF文件并输出含源文件名及页码的文件?

解决pdftk批量拆分多PDF并保留源文件名+页码的问题

pdftk的burst命令不支持同时处理多个PDF文件,直接执行pdftk *.pdf burst会因输入参数格式错误触发"Input errors, so no output created."提示。要实现批量拆分且输出文件包含源文件名和页码,需通过循环逐个处理每个PDF:

Bash/Linux/macOS 环境

用for循环遍历目录下所有PDF,对每个文件单独执行burst:

for file in *.pdf; do
  pdftk "$file" burst output "${file%.pdf}.%02d.pdf"
done
  • ${file%.pdf}会移除文件名的.pdf后缀,%02d表示用两位数字格式输出页码(不足两位补零),最终输出文件形如sample.01.pdf、sample.02.pdf。
  • 若不需要页码补零,可将%02d改为%d;需要三位数字页码则用%03d。

PowerShell/Windows 环境

用管道遍历PDF文件并处理:

Get-ChildItem -Filter *.pdf | ForEach-Object {
    pdftk $_.FullName burst output "$($_.BaseName).%02d.pdf"
}

内容的提问来源于stack exchange,提问作者CatWazel67

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 08:49:56