I would like to rename all directories under a basedir which match a name. For example:

In basedir/, I have:

- foo/bar/blah
- my/bar/foo
- some/bar/foo1
- other/foo/bar

I would like to rename all directories matching bar, but I would like to preserve the prefix part.

With find, I can easily make a list of all the directories like this:

find . -name repositoryunit -type d

However, how can I use -exec mv {} ... (or perhaps combine with another app) so that the prefix is preserved?

Many thanks in advance!

Edit
Report