I have a Rails 3 app which needs to have some directories created. I'd like to have a rake task which I can run to do this as a sort of initialization procedure. Basically I'd like to do:  rake app:create_dirs or something similar. I tried using the "directory" commands but they seem to be only for dependencies in rake. Any ideas how to do this nicely? My dir structure needs to loo开发者_运维技巧k like this:
public/content/0/0
public/content/0/1
public/content/0/2
...
public/content/1/0
public/content/1/1
...
public/content/n/m
where n is 0..9 and m is 0..9
Thanks for any advice.
Something like this should work, I don't know your exact application but the main point is to look into FileUtils#mkdir_p
require 'fileutils'
(0..9).each do |n|
  (0..9).each do |m|
    FileUtils.mkdir_p("#{Rails.public_path}/content/#{n}/#{m}")
  end
end
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论