I need to recursively append the same suffix to all sub-directory names in a directory. What is a simple and safe way to do this?
1 Answer
Using find and rename:
find . -depth -type d -not -name '.' -exec rename -n 's/(.*)/$1_foo/' {} +This will add suffix _foo to all directories recursively, -n will show the names of the directories that will be changed.
If you are satisfied with the names you can remove the -n option to let the action take place:
find . -depth -type d -not -name '.' -exec rename 's/(.*)/$1_foo/' {} + 8