shellfindandmodify

Find and replace string in folder name using command line


How can I replace a string in all my folder names in one directory. For example if I have these folders

hellojoe hellomary hellosusan

I want to change these to

worldjoe worldmary worldsusan


Solution

  • Using this command works

    find . -name 'hello*' -exec bash -c 'mv "$1" "${1/hello/world}"' -- {} \;