1

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

3
  • Are you trying to avoid changing the names of regular files? Commented Apr 15, 2020 at 15:22
  • Yes I would like to change the folder names only, without touching the files. In my case, that's not a concern, since there are no files in that folder, so my provided answer works. But being more explicit would make a better answer of course. Commented Apr 15, 2020 at 18:16
  • 1
    In the answer you've given, just add -type d to restrict to directories. Commented Apr 15, 2020 at 19:56

1 Answer 1

2

Using this command works

find . -name 'hello*' -exec bash -c 'mv "$1" "${1/hello/world}"' -- {} \;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.