PDFtk密码保护帮助

戴夫W.

我正在使用Ubuntu 11.10,正在寻找一种解决方案,以密码保护批量保护目录中的pdf文件。我碰到了PDFtk,看起来它可能可以满足我的需要,但是我已经查看了PDFtk命令行示例,无法找出是否有一种方法可以批量进行而不必单独指定输出文件名对于每个文件。我希望命令行专家可以看一下PDFtk语法,并告诉我是否有一些技巧/命令可以让我用密码保护pdf文件的目录(例如* .pdf)并覆盖现有目录使用相同名称的文件,或一致地重命名各个输出文件,而不必分别指定每个输出名称。

这是指向PDFtk命令行示例页面的链接:http ://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

谢谢你的帮助。


我想我已经回答了我自己的问题。这是一个似乎可以解决问题的bash脚本。我很乐意帮助评估为什么我注释掉的代码不起作用...

#!/bin/bash
# Created by Dave, 2012-02-23
# This script uses PDFtk to password protect every PDF file
# in the directory specified. The script creates a directory named "protected_[DATE]"
# to hold the password protected version of the files.
# 
# I'm using the "user_pw" parameter, 
# which means no one will be able to open or view the file without
# the password.
#
# PDFtk must be installed for this script to work.
#
# Usage: ./protect_with_pdftk.bsh [FILE(S)]
# [FILE(S)] can use wildcard expansion (e.g., *.pdf)

# This part isn't working.... ignore. The goal is to avoid errors if the
# directory to be created already exists by only attempting to create
# it if it doesn't exists
#
#TARGET_DIR="protected_$(date +%F)"
#if [ -d "$TARGET_DIR" ]
#then
    #echo   # echo "$TARGET_DIR directory exists!"
#else
    #echo   # echo "$TARGET_DIR directory does not exist!"
#fi
#

mkdir protected_$(date +%F) 
for i in *pdf ; do pdftk "$i" output "./protected_$(date +%F)/$i" user_pw [PASSWORD]; done 
echo "Complete. Output is in the directory: ./protected_$(date +%F)"
戴夫W.

上面的海报要求我重新张贴我的答案,作为后代的实际答案。这就是答案。感谢大家的帮助。


我已经回答了我自己的问题。这是一个似乎可以解决问题的bash脚本。我很乐意帮助评估为什么我注释掉的代码不起作用...

#!/bin/bash
# Created by Dave, 2012-02-23
# This script uses PDFtk to password protect every PDF file
# in the directory specified. The script creates a directory named     "protected_[DATE]"
# to hold the password protected version of the files.
# 
# I'm using the "user_pw" parameter, 
# which means no one will be able to open or view the file without
# the password.
#
# PDFtk must be installed for this script to work.
#
# Usage: ./protect_with_pdftk.bsh [FILE(S)]
# [FILE(S)] can use wildcard expansion (e.g., *.pdf)

# This part isn't working.... ignore. The goal is to avoid errors if the
# directory to be created already exists by only attempting to create
# it if it doesn't exists
#
#TARGET_DIR="protected_$(date +%F)"
#if [ -d "$TARGET_DIR" ]
#then
#echo   # echo "$TARGET_DIR directory exists!"
#else
#echo   # echo "$TARGET_DIR directory does not exist!"
#fi
#

mkdir protected_$(date +%F) 
for i in *pdf ; do pdftk "$i" output "./protected_$(date +%F)/$i" user_pw    [PASSWORD]; done 
echo "Complete. Output is in the directory: ./protected_$(date +%F)"

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章