views:

32

answers:

1

I am using the convert command to convert a pdf to multiple pngs, I need the naming conventions to be slide-##.png at the moment they come out like slide-1.png but because there is 20+ slides when I loop through them to add them into the model the order comes up wrong, so it looks like slide-1.png slide-10.png slide-11.png and so on, how can I force convert to use double numbers like 01 02 03 and so forth or is there a better way to loop through them, this is the code I have at the moment

  def convert_keynote_to_slides
    system('convert -size 640x300 ' +   keynote.queued_for_write[:original].path + ' ~/rails/arcticfox/public/system/keynotes/slides/'+File.basename( self.keynote_file_name )+'0%d.png')

    slide_basename = File.basename( self.keynote_file_name )

    files = Dir.entries('/Users/joshcrowder/rails/arcticfox/public/system/keynotes/slides')
    for file in files
      #puts file if file.include?(slide_basename +'-')
      self.slides.build("slide" => "#{file}") if file.include?(slide_basename)
    end

  end
+2  A: 

use the convert command with a c-style format for the slide index number:

%02d.png

JohnR
That worked great thanks!
Josh Crowder