Rename multiple directories

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

Answer

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

Attribution
Source : Link , Question Author : Marc , Answer Author : rush

Leave a Comment