如何批量解密一系列PDF文件?

Glu*_*ate 7 pdf password batch decryption

我有一堆 PDF 文档,我知道密码并想解密它们。我怎样才能做到这一点?

Glu*_*ate 7

鹦鹉螺脚本

可以通过脚本轻松实现此任务的自动化:

#!/bin/bash

# AUTHOR:       (c) Glutanimate 2012 (http://askubuntu.com/users/81372/)
# NAME:         PDFdecrypt 0.3
# DESCRIPTION:  A script to batch decrypt PDF files.
# DEPENDENCIES: qpdf zenity libnotify-bin 
#               (install via sudo apt-get install qpdf zenity libnotify-bin)
# LICENSE:      GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# CHANGELOG:    0.3 - added notifications and basic error checking
#               0.2 - replaced obsolete gdialog with zenity

password=$(zenity --password --title "PDF Password required")

RET=$?

if [[ $RET = 0 ]]; then

  while [ $# -gt 0 ]; do
      ENCRYP=$1
      DECRYP=$(echo "$ENCRYP" | sed 's/\.\w*$/_decrypted.pdf/')
      qpdf --password=$password --decrypt "$ENCRYP" "$DECRYP"
      RET=$?
      if [[ $RET != 0 ]]; then
        ERR=1
      fi
      shift
  done

  if [[ $ERR = 1 ]]
    then
        notify-send -i application-pdf "PDFdecrypt" "All documents processed.There were some errors"
    else
        notify-send -i application-pdf "PDFdecrypt" "All documents decrypted."
  fi

else
  exit
fi
Run Code Online (Sandbox Code Playgroud)

注意:此脚本取决于qpdf,zenitylibnotify-bin。使用脚本中提供的命令安装它们。


用法

将上面文本框的内容复制并粘贴到一个新的空文档中(在文件管理器中右键单击:创建新文档-->空文档)并将其另存为Decrypt PDFs.

通过将其标记为可执行文件(右键单击文件 -->属性-->权限 --> 选中允许将文件作为程序执行)。

如果您正在运行 Ubuntu,您可以通过将其复制到~/.gnome2/nautilus-scripts. 您现在可以通过选择 PDF,右键单击并前往Scripts --> Decrypt PDFs解密 PDF。享受!