Created
March 25, 2022 18:10
-
-
Save vyder/47be88ae0c6933f16f1a39a75eae7230 to your computer and use it in GitHub Desktop.
Ruby script to batch unlock pdfs in-place using qpdf (installed via homebrew)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
files = ARGV.dup | |
password = files.shift | |
cmd = "qpdf" | |
options = "--decrypt --password=#{password} --replace-input" | |
files.each do |filename| | |
print "Unlocking #{filename}..." | |
%x(#{cmd} #{filename.inspect} #{options}) | |
puts "Done." | |
end | |
puts "All Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment