R
Rebhan, Gilbert
Hi,
i want to copy a dir recursive with all files included,=20
but rename all dirnames that match a pattern, i.e.
/srcdir
/bla/foobar/blabla
/bla/test/subtest/foobar
/foobar/test
/foobar
should be=20
/targetdir
/bla/foobaz/blabla
/bla/test/subtest/foobaz
/foobaz/test
/foobaz
i tried =3D
re=3D/foobar/
sub=3D"foobaz"
Dir['Y:/test/**/**'].each { |old|
next if old =3D=3D '.'||old=3D=3D '..'||old =3D~ /\./
unless /re/.match(old)
new =3D old.sub(re,sub)
File.rename(old,new)
end
}
the /foobar folder on first level and on second level get renamed, but
it dosn't
work, when i have /foobar on the third level, means
/foobar/foobar/foobar gets=20
/foobaz/foobaz/foobar and Exit Code 1
/test/sub3/foobar/foobar gets
/test/sub3/foobaz/foobar and Exit Code 1
Error message i.e. =3D
No such file or directory - Y:/test/sub3/foobar/foobar or
Y:/test/sub3/foobaz/foobar
Any ideas what's wrong ?
Regards, Gilbert
i want to copy a dir recursive with all files included,=20
but rename all dirnames that match a pattern, i.e.
/srcdir
/bla/foobar/blabla
/bla/test/subtest/foobar
/foobar/test
/foobar
should be=20
/targetdir
/bla/foobaz/blabla
/bla/test/subtest/foobaz
/foobaz/test
/foobaz
i tried =3D
re=3D/foobar/
sub=3D"foobaz"
Dir['Y:/test/**/**'].each { |old|
next if old =3D=3D '.'||old=3D=3D '..'||old =3D~ /\./
unless /re/.match(old)
new =3D old.sub(re,sub)
File.rename(old,new)
end
}
the /foobar folder on first level and on second level get renamed, but
it dosn't
work, when i have /foobar on the third level, means
/foobar/foobar/foobar gets=20
/foobaz/foobaz/foobar and Exit Code 1
/test/sub3/foobar/foobar gets
/test/sub3/foobaz/foobar and Exit Code 1
Error message i.e. =3D
No such file or directory - Y:/test/sub3/foobar/foobar or
Y:/test/sub3/foobaz/foobar
Any ideas what's wrong ?
Regards, Gilbert