Directory Management – How to Rename Multiple Directories

directoryfindrename

I want to find all directories with the last subdirectory named doc, for then rename them to Doc. How can be renamed?

I've the first part:

find -type d -name 'doc' 

which returns directories paths like:

./foo/bar/doc

Best Answer

find . -depth -type d -name doc -exec sh -c 'mv "${0}" "${0%/doc}/Doc"' {} \;
Related Question