From: "Rebhan, Gilbert" Date: 2007-06-14T18:53:20+09:00 Subject: Re: Dir copy with rename Hi, -----Original Message----- From: Mariusz Pekala [mailto:skoot@ideico.net] Sent: Thursday, June 14, 2007 11:26 AM To: ruby-talk ML Subject: Re: Dir copy with rename > Dir['Y:/test/**/**'].each { |old| > next if old == '.'||old== '..'||old =~ /\./ > unless /re/.match(old) > new = old.sub(re,sub) > File.rename(old,new) > end > } now i have src="Y:/test" re=/foobar/ sub="foobaz" Dir[src+'/**/**/**'].each { |old| next if old == '.'||old== '..'||old =~ /\./ puts old if re.match(old) new = old.sub(re,sub) File.rename(old,new) end } when i use Dir[src] the /foobar folder on first level, means Y:/test/foobar gets Y:/test/foobaz and Exit 0 but when i use Dir[src+'/**'], because i want to recurse in all subfolders the folder on first level gets renamed and then i get an error = >ruby dircopy.rb Y:/test/sub3 Y:/test/sub1 Y:/test/foobar Y:/test/sub3/foobar Y:/test/sub3/foobar/foobar dircopy.rb:14:in `rename': No such file or directory - Y:/test/sub3/foobar/foobar or Y:/test/sub3/foobaz/foobar (Errno::ENOENT) Regards, Gilbert