From: Phillip Gawlowski Date: 2009-12-18T22:41:52+09:00 Subject: Re: moving a file after processing On 18.12.2009 14:24, bingo bob wrote: > I'm working on a script and trying to move the file processed to a > subdir after processing. Here's an cut down extract of my code... > > # example code starts > require 'ftools' > basedir = "#{RAILS_ROOT}/data_files/resort_photos/" > target = "#{RAILS_ROOT}/data_files/resort_photos/processed" > > Dir["#{RAILS_ROOT}/data_files/resort_photos/*.*"].each do |file| > # process one file at a time > > # lets state the filename > puts "Processing: #{file}" > > puts "Moving...." > file.move(basedir + file, target + file) # What should I be doing > here ? > puts "Moved..." > > end > > # example code stops Ruby's FileUtils should do what you want: http://ruby-doc.org/core/classes/FileUtils.html#M004331 require 'fileutils' #this is a guess, but should work FileUtils.mv 'badname.rb', 'goodname.rb' -- Phillip Gawlowski