Recursively search for all directories containing "foo" (case insensitive) under the current directory, renaming them to replace "foo" (case insensitive) with "Bar"
find . -type d -iname '*foo*' -depth -exec rename 's@Foo@Bar@gi' {} +