From: Bee Tard Date: 2008-10-29T08:33:41+09:00 Subject: Re: createing directories and moving files into it Axel Etzold wrote: > you can create a directory, if it doesn't yet exist, using fileutils: > > irb(main):001:0> require "fileutils" > => true > irb(main):002:0> FileUtils.mkdir_p "temp5" > => "temp5" > > If you do it again, that doesn't matter. > For moving files, I like the rio gem: > > http://rio.rubyforge.org/ > > require "rubygems" > require "rio" > > Iterate over the .rb files in a directory and its subdirectories. > > rio('adir').all.files('*.rb') { |entrio| > > # do some checks on entrio.to_s to classify things > > if /\.jpg$/.match(entrio.to_s) > p "it's an image > end > > } > > Do also check that you have writing permissions on the directory you > want to write to. > I did it this way: for I in *; do mkdir ${I}/myFolder; mv ${I}/* ${I}/myFolder; done was wondering forever about a ruby way. thanks for the help. -- Posted via http://www.ruby-forum.com/.