合并PDF文件使用PDFTK和bash脚本相似的名称 [英] Merging PDF files with similar names using PDFTK and a bash script

查看:224
本文介绍了合并PDF文件使用PDFTK和bash脚本相似的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几百个PDF文件的目录中了。

I have a directory with a few hundred PDFs in it.

所有文件名以一个5位数的数字开头(然后在结尾一堆其他的东西)的PDF文件。

All of the PDFs filenames begin with a 5 digit number (and then have a bunch of other stuff at the end).

我需要做的是合并任何的PDF在一起同为5位数字开始的。

What I need to do is merge any PDFs together that start with the same 5 digit number.

如何通过一个shell脚本做到这一点的想法?或者其他的选择?我使用 PDFTK 在Ubuntu

Thoughts on how to do this via a shell script? Or other options? I'm using pdftk on Ubuntu.

推荐答案

试试这个:

find . -type f -iname "[0-9][0-9][0-9][0-9][0-9]*.pdf" -printf "%.5f\n" \
  | sort -u \
  | while read -r file; do 
         echo pdftk ${file}*.pdf cat output $file.pdf ;
    done

如果输出是好的,删除回声

If output is okay, remove echo.

这篇关于合并PDF文件使用PDFTK和bash脚本相似的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆