Skip to content

Instantly share code, notes, and snippets.

@vyder
Created March 25, 2022 18:10
Show Gist options
  • Save vyder/47be88ae0c6933f16f1a39a75eae7230 to your computer and use it in GitHub Desktop.
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)
#!/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