From: Heesob Park Date: 2009-08-08T12:44:25+09:00 Subject: Re: I want a script can do this Hi, 2009/8/8 Jacky Cheung : > I want a script can do this: > a directory aa , under aa has many files. i want batch rename all files. > like this > the file name is test01 test02 test03 ... test09 test10 test11... test29.... > rename > test1 test2 test3 ....test9 test10 test29..... > > how can i write this script? > Try this: Dir.glob("aa/*").each{|f|File.rename(f,f.gsub(/test0+(?=\d)/,"test"))} Regards, Park Heesob