1

I am trying to rename directories, files and text inside them recursively I am using rename brew formula on macOS Sierra.

find . -type f -exec rename 's|{{ cookiecutter.name }}|QWERTYUIOPASDF|' * {} +

Here is the Dry Run with -n command

'{{ cookiecutter.name }}' would be renamed to 'QWERTYUIOPASDF'
'./{{ cookiecutter.name }}/Sources/{{ cookiecutter.name }}.h' would be renamed to './QWERTYUIOPASDF/Sources/{{ cookiecutter.name }}.h'

But in execution the root directory is renamed from {{ cookiecutter.name }} to QWERTYUIOPASDF

but for the subdirectories it shows

'./{{ cookiecutter.name }}/Sources/{{ cookiecutter.name }}.h' not renamed: './QWERTYUIOPASDF/Sources/{{ cookiecutter.name }}.h' already exists

obviously because it is trying to find

./{{ cookiecutter.name }}/Sources/{{ cookiecutter.name }}

which has now changed to

./QWERTYUIOPASDF/Sources/{{ cookiecutter.name }}

How can I fix this ?

And also how can I use sed -i 's/{{ cookiecutter.name }}/QWERTYUIOPASDF/g' to rename all text inside all files recursively

bfontaine
  • 18,169
  • 13
  • 73
  • 107
Rahul Katariya
  • 3,528
  • 3
  • 19
  • 24

0 Answers0