From: Li Chen Date: 2006-11-27T05:12:09+09:00 Subject: How to re-name a file from Ruby script Hi all, I have a folder containing many files with format LIPID5-2.001 LIPID5-2.002 ... LIPID5-2.200 I want to change all of them into LIPID5-3.001 LIPID5-3.002 ... LIPID5-3.200 I write a script as follows. Based on the screen output the filename is changed. But I go to the same folder and find the original file LIPID5-2.001 is still there and there is no file called LIPID5-3.001. Any comments? Thanks, Li ## path='C:\Ruby\self' Dir.entries(path).each do |filename| if filename=~/(LIPID5-2)(\.\w+)/i p filename.gsub!(/LIPID5-2/,'LIPID5-3') end end ##output >ruby dir9.rb "LIPID5-3.001" >Exit code: 0 -- Posted via http://www.ruby-forum.com/.