Peter Bailey wrote: > Hello. > I need to parse through thousands of TIFF files and do some re-naming. > These files have underscores in them followed by a sequential number. I > need to grab just the "root" of the filename, without the underscore or > the numbers. > Dir.chdir("L:/infocontiffs/ehs-g7917741") > files = Dir.glob("*.tiff") > file = files[0] > puts file > file = file.gsub(/^(.*)_[0-9]+\.tiff/, "#{$1}") The argument "#{$1}" is expanded once, before gsub even executes. You probably want the block form: file = file.sub(/^(.*)_\d+\.tiff/) { $1 } -- Posted via http://www.ruby-forum.com/.