24Feb/091
How to recursively rename directories using a regexp
RT @thibauld How to recursively rename directories using a regexpJust a very quick post because I just figured out a command to recursively rename directories. As it is the kind of useful commands you don't want to loose and as it might be of interest for others, I thought I would share it here. So here is the command:
find -type d -name '*-test' | while read A; do OLD=$(basename $A); NEW=$(echo $OLD | sed s/-test//); mv $A $(dirname $A)/$NEW; done;
In this example, the command recursively finds all directories named <anything>-test and renames them <anything> (removing the trailing '-test'). I hope it will be useful for some of you...