in reply to File::Find: Problem with renaming folders recursively

See: Need to delete empty directories.[ you need to go into "depth first" mode, so that you don't change topdir names, before changing topdir's subdirs.
#!/usr/bin/perl use File::Find; finddepth sub { #return if $_ eq "." or $_ eq ".."; return unless -d; rmdir($_); if($! =~ /not empty/){warn "$File::Find::name $!"} }, @ARGV;

I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness

Replies are listed 'Best First'.
Re^2: File::Find: Problem with renaming folders recursively
by larus (Acolyte) on Mar 20, 2009 at 15:28 UTC
    I don't want to remove those dirs, I want to rename them.
      Well then, just take the code, take out the rmdir, and put in a rename. What? Are we supposed to write all your code for you? Just setup a test dir/subdir setup, and try renaming, with finddepth, instead of find. Also Google for "File::Find rename dirs"

      I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness
        oh, not at all. I'm quite surprised that after an hour googling I haven't found any ready solution for this problem. Perl has been one of the "big" programming languages for decades and there is no "quick" solution for this simple (for experienced programmer) problem.