From: Aldric Giacomoni <"aldric[remove]"@...> Date: 2008-12-16T01:17:53+09:00 Subject: Walk through directory structure, look at first file, rename dir in consequence. This is pretty ugly and doesn't work.. Can't figure out why, but it doesn't actually go through the main loop more than once. I'm a little stuck here.. Any help is welcome :) def keep_iterating_until_not_directory() Dir.glob('*') do |filename| if File.directory?(filename) Dir.chdir(filename) keep_iterating_until_not_directory() end break end end def come_back_to_nycom Dir.chdir("..") while Dir.pwd != "C:/Documents and Settings/username/My Documents/NYCOM" end Dir.glob('*') do |filename| if File.directory?(filename) keep_iterating_until_not_directory() end puts Dir.pwd image = DICOM::DObject.new(Dir.glob('*')[0], verbose=false, library=lib) come_back_to_nycom() if image.get_raw("0008,1090") == "HDI 5000" File.rename(filename, "HDI5000" + filename) end end