Hi, -----Original Message----- From: Robert Klemme [mailto:shortcutter / googlemail.com] Sent: Thursday, June 14, 2007 12:05 PM To: ruby-talk ML Subject: Re: Dir copy with rename > 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 > } /* Your basic flaw seems to be that although the subject talks about "copy with rename" your code actually only renames. That will lead to errors because you change the original directory tree and thus a file further down the hierarchy of a renamed folder does not exist any more with the original file name - hence you cannot rename it. */ OK, so i need to copy the whole structure and to do the substitution of pathname when creating the new pathname, but i don't get it tried things like = Dir[src+'/**/**'].each { |old| next if old == '.'||old== '..'||old =~ /\./ if re.match(old) puts old.sub(src,destdir).sub(re,sub) Dir.new(old.sub(src,destdir).sub(re,sub)) File.open(old.sub(src,destdir).sub(re,sub),"w+") end } but that doesn't work. Any hints appreciated. Regards, Gilbert