How to Rename a Directory in Linux With mv, rename, or find command
How to rename a directory in Linux using the mv
, rename
, and find
commands, along with information on installing rename
and regular expressions for changing directory names to lowercase or uppercase?
Renaming a Directory in Linux
Using mv Command:
mv old_directory_name new_directory_name
Using rename Command:
rename 's/old_directory_name/new_directory_name/' *
Using find Command:
find . -depth -name 'old_directory_name' -execdir mv {} new_directory_name \;
Installing rename in Linux
For Debian/Ubuntu:
sudo apt-get install rename
For RedHat/CentOS:
sudo yum install rename
Regular Expressions for Directory Name Changes
Change All Letters to Lowercase:
rename 'y/A-Z/a-z/' *
Change All Letters to Uppercase:
rename 'y/a-z/A-Z/' *
This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.