Hi,

finally with your help and the snippets of another thread =

'Directory tree traversal fun'

i have a working solution with Ruby 1.8.4 (all-in-one) on windows.


is there anything wrong, something that could be done better
in following snippet ?

require 'fileutils'
require 'find'
require 'pathname'

srcdir="Y:/test"
destdir="Y:/test_"
torepl="foobar"
replwith="foobaz_"

# Method from thread  'Directory tree traversal fun'
def rename(headOfTree, what, withWhat)
  p = Pathname.new(headOfTree)
  p.find() do |file|
    path = file.to_s #just to make it prettier
    File.rename(path, path.gsub("#{what}", withWhat)) if
path.include?(what)
  end
end

Dir.mkdir(destdir) unless File.exists?(destdir)

Dir.entries(srcdir).each do | i | 
  if i !='.' && i !='..'
    FileUtils.cp_r Dir["#{srcdir}/**"], destdir
  end
end

Find.find(destdir) do |file|
  if File.directory?(file)
    rename(file,torepl,replwith)
  end  
end


**********
still it's not working with jruby within ant via <script> task though
:-( 

%JRUBY_HOME% set
%JRUBY_HOME%/bin in path
jruby.jar in %ANT_HOME%/lib
**********

thanks in advance !!


Regards, Gilbert