How to Rename Directories in Linux Mint 20

How to Rename Directories in Linux Mint 20


Maintaining a structured file system is a necessity rather than a recommendation for system administrators. In this article, you will learn how to rename your directories in Linux Mint 20 to organize your files.

Find Your Current Working Directory

First of all, you will need your directory path/name to follow this tutorial. In case you do not know your current directory, run the following command in the terminal.


List Down Directories/Files in Your Current Directory

List down all the directories and files in your current directory and verify the renamed directories with the following command.


Rename Directories Using mv Command

To change your directory name, use the following mv command with your source and target directory.

mv <source_directory> <target_directory>

You can see the results in listing down your directory contents. In the above snippet, you can see that the former ‘test’ directory is renamed to ‘testdirectory’.

Rename Directories Using rename Command

Alternatively, you can use the rename command to rename directories which is a more detailed built-in command.

To change a directory name, run the following command.

rename ‘s/<old-name>/<new-name>/’ *

As a result, you can see the ‘test0’ directory was renamed to ‘directory’ in the following snippet.

Rename command can be used to rename multiple directories and files names at once. For example, you can change all the directory’s names to lowercase with the following command.

rename 'y/A-Z/a-z/' *

Rename multiple Directories With find Command

For more complex renaming purposes, you can use the find command in combination with mv and rename command.

Note: mv command can only rename a single directory at a time. To make multiple changes you need to run it in combination with the find command.

Run the following command to change a directory name.

find . -depth -type d -name <source_directory> -execdir mv {} <target_directory> \;

‘-type’ option will look for the directory while ‘-exexdir’ option will let the directory be renamed with mv command.

You can make filesystem-wide directory changes with the find command. It comes in handy in particular, when you do not know where your targeted directory lies.

In the following command, the find command is run in combination with the rename command to change all directory names to lowercase.

find . -mindepth 1 -prune -type d | rename 'y/A-Z/a-z/'


Keeping an organized file system brings merit not only to system administrators, but regular users can also benefit from it. In this article, you have learned all the ways you can organize your directories in your Linux Mint system.

Similar Posts