L
Li Chen
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
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