how to create path subdirectories

K

kean

Hi-
looking for a way to create /test1/test2/test3/test4 subdirectories all
together. I was looking at Dir.mkdir but can't do
Dir.mkdir("./test1/test2/test3/test4"). I'm pretty new in ruby and not
sure how to do it the ruby way ... the only way I can think of is to do
a array loop to make the dir. And maybe someone has write a code about
it. any help or suggestion?

kean
 
G

gabriele renzi

Hi-
looking for a way to create /test1/test2/test3/test4 subdirectories all
together. I was looking at Dir.mkdir but can't do
Dir.mkdir("./test1/test2/test3/test4"). I'm pretty new in ruby and not
sure how to do it the ruby way ... the only way I can think of is to do
a array loop to make the dir. And maybe someone has write a code about
it. any help or suggestion?

kean
require 'fileutils'
FileUtils.mkdir_p 'ciao/miao/bau'
oh, and welcome to ruby :)
 
J

Joel VanderWerf

kean said:
Hi-
looking for a way to create /test1/test2/test3/test4 subdirectories all
together. I was looking at Dir.mkdir but can't do
Dir.mkdir("./test1/test2/test3/test4"). I'm pretty new in ruby and not
sure how to do it the ruby way ... the only way I can think of is to do
a array loop to make the dir. And maybe someone has write a code about
it. any help or suggestion?

No loop needed :)

require 'ftools'
File.mkpath('test1/test2/test3/test4')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,352
Latest member
DianeKulik

Latest Threads

Top