Recursively creating a set of directories in Ruby

class Dir
  def self.mkdirs(p)
     return if File.exists?
     dir, file = File.split(p)
     Dir.mkdirs(dir) if !File.exists?(dir)

#sample usage: Dir.mkdirs(‘test/tmp/tempest’)

3 thoughts on “Recursively creating a set of directories in Ruby”

  1. @Ari
    There goes my 15 secs of fame to the dumps – showcasing my bad googling skills. Btw, thank you for the tip!

    Btw thank you for providing the link to your site. Its a great resource and my weekend read!

Leave a Reply

Your email address will not be published. Required fields are marked *