Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to rename all files and directories containing non-word characters (windows system) under a specific directory using File::Find. Problem is that if I rename the directories as FileFind finds them then it gets tripped up trying to chdir to directories below it because (I guess) that directory has been renamed. How can I get around this? Thanks in advance.

Replies are listed 'Best First'.
Re: Rename Using File::Find
by pfaut (Priest) on Jan 14, 2003 at 21:59 UTC

    You want to process depth first. Use finddepth instead of find. It's in the documentation for File::Find.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
Re: Rename Using File::Find
by gjb (Vicar) on Jan 14, 2003 at 22:07 UTC

    You could use File::Find's finddepth rather than find to do a depth-first search. That way you'll rename those file/directories at the bottom of the directory tree first,.

    Hope this helps, -gjb-