#!/usr/bin/env ruby require 'iconv' input = ARGV[0] outdir = ARGV[1] ps = File.open(input).read title = /%%Title: (.+)\s+/.match(ps)[1] if title[0] == 60 # '<' char chars = title.gsub(/[<>]/, '').scan(/../) title = chars.pack("H2" * chars.size) end title = Iconv.conv("UTF-8", "ISO-8859-2", title.strip).strip outfile = "#{outdir}/#{title}.pdf" options = "" system("ps2pdf #{options} #{input} '#{outfile}' > /dev/null") system("chmod 777 '#{outfile}'") system("rm #{input}")