From: "Peña, Botp" Date: 2008-10-29T10:29:01+09:00 Subject: Re: createing directories and moving files into it From: Bee Tard [mailto:scappa@gmail.com] # I did it this way: # for I in *; do mkdir ${I}/myFolder; mv ${I}/* ${I}/myFolder; done you can do that too system "for I in *; do mkdir ${I}/myFolder; mv ${I}/* ${I}/myFolder; done" i'm joking of course ;) that is fine if you have only folders/directory (ie no regular files) in your current dir, and your folders contain just images. in a full-fledged language, your checking is flexible, and your code is portable. plus you get the power of ruby. anyway, try eg, require 'fileutils' Dir.glob("tempf/*").select{|x| FileTest.directory?(x)}.each{|dir| dest_folder = File.join(dir,"images") srce_files = Dir.glob(File.join(dir,"*.jpg")) Dir.mkdir dest_folder FileUtils.mv srce_files, dest_folder } note, tempf is just my sample test folder to test the code above.