Marco Romano
Marco Romano's Blog

Follow

Marco Romano's Blog

Follow

How to massively rename directories in a project

Marco Romano's photo
Marco Romano
·Mar 14, 2023·

1 min read

I recently had to change the package name of a project I'm working on but somehow the IDE didn't manage to adjust the name of the directories accordingly.

Turns out there's a command line utility called rename that can be helpful in such situations.

You can install it with your favorite package manager e.g.

brew install rename

And then you can use it as such:

find ./ -type d -name oldname -execdir rename 's/oldname/newname/g' '{}' \+;

This will use the find command to find all subdirectories of the current directory named "oldname" and then will execute the rename command to rename each of them from "oldname" to "newname".

 
Share this