From: 7stud -- Date: 2009-04-27T13:20:25+09:00 Subject: Re: Creating directory and its files Martin Sharon wrote: > Hi there: > I want to create a directory and create files under it. > I can use > > FileUtils.mkdir_p ARGV[0] > > to create a directory, however if the directory already exist, program > will > generate error messages: > How about posting what you want to do if the directory already exists? If you want to overwrite it(=delete it), then first check if the directory exists: if File.exist?("dirname") If it does, then: if File.exist?("dirname") FileUtils.remove_dir("dirname") end But that is playing with fire. You could end up deleting your whole hard drive if you get the right file name in there. A safer option would be to rename the old dir, and then create the new dir. -- Posted via http://www.ruby-forum.com/.