#!/usr/bin/ruby

srcdirs = ["figs"]
destdirs = ["figs"]

srcdirs.each_with_index{ |srcdir,idir|
  destdir = destdirs[idir]
  Dir.glob( srcdir+"/*.pdf" ) do |item|
    item.chomp!
    if ( item[-9..-1] != "-crop.pdf" ) then
      outfile = destdir+"/"+item[(item.rindex("/")+1)..-5]+"-crop.pdf"
      com = "pdfcrop "+item+" "+outfile
#    p com
      system( com )
    else
      print item, " is skipped.", "\n"
    end
  end

}
