Skip to content

Instantly share code, notes, and snippets.

@ecentinela
Created February 18, 2011 18:29
Show Gist options
  • Save ecentinela/834154 to your computer and use it in GitHub Desktop.
Save ecentinela/834154 to your computer and use it in GitHub Desktop.
Convert multiple jpg files to a pdf document
# get the actual directory
root_path = Dir.pwd
# all files on the actual directory
Dir.glob(File.join root_path, '*').each do |file|
# check that is a directory
if File.directory? file
print "Converting #{file}... "
# path where image files are
path = File.join file, '*.jpg'
# use imagemagick convert command
`/usr/local/bin/convert '#{path}' '#{file}.pdf'`
puts 'done!'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment