将一页PDF自动合并为两页PDF



我知道有像pdftk或convert或ghostscript这样的工具。但我的搜索失败了,因为所有的解决方案都是为2个pdf文件合并到1个pdf文件而构建的。

但我有30000个PDF文件,想把它们合并成15000个双面PDF文件。因为第一页在前面,第二页在后面。我需要将它们组合在一个pdf文件中,包括正面和背面。

它们从00001.pdf和00002.pdf开始编号,需要组合成一个新的两页pdf。然后是00003.pdf和00004.pdf,依此类推。有没有机会构建一个命令,自动抓取下一个pdf并合并它们?

另一种选择,我想到了一个";尺寸断裂";每个文件的大小接近2.5MB。一个只构建5MB pdf然后转到下一个文件的命令。

谢谢你的建议。

附言:我也有.jpg格式的所有文件。

在Bash中,类似于以下内容:

#! /bin/bash
fileIndex=1
inputFormat="%05d.pdf"        # change the formats 
outputFormat="%05d+%05d.pdf"  # to support other name patterns
while true
do
file1root=$((fileIndex++))
file2root=$((fileIndex++))
printf -v file1 "$inputFormat" "$file1root"
printf -v file2 "$inputFormat" "$file2root"
printf -v output "$outputFormat" "$file1root" "$file2root"
[[ -f $file1 ]] && [[ -f $file2 ]] || break
echo execute some command $file1 $file2 $output ####
done

其中####行被一个将两个PDF合并为一个PDF 的命令所取代

最新更新