How to Rename Multiple Directories in Ubuntu 22.04?


In Ubuntu 22.04, the mv (move) command is used to rename a single directory. There might occur a requirement to rename multiple directories. Using the mv command repeatedly to rename the directories one by one can be time-consuming, ineffective, and irritating for the user. This article will illustrate the process of renaming multiple directories in Ubuntu 22.04 LTS by using the following methods:

  • Rename
  • Qmv
  • Mmv
  • Find
  • Ubuntu UI
  • Gprename
  • Thunar File Manager

The following sections will demonstrate the renaming of multiple directories, i.e., “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” located in the “Extra” directory to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

How to Rename Multiple Directories via Rename Utility in Ubuntu 22.04?

Rename Utility aids to rename directories and files in bulk. Rename utility is not pre-installed in Ubuntu 22.04. To install the “rename” utility in an Ubuntu 22.04 system, first, update the system repositories by running the following command:


Then, execute the following command to install the rename utility:


The above output indicates the successful installation of the “rename” utility. In order to rename the directories: “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”, first, navigate to the “Extra” via cd command:


Where “Extra” is the directory which contains “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5”. Then, run the following command:
$ rename ‘s/Directory/Folder/’ Directory*

Where,

  • s/Directory/Folder/: substitute expression
  • Directory*: all directories in the particular directory

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”. Additionally, the “rename” utility can also be used to convert cases, i.e., upper and lower cases.

How to Rename Multiple Directories via Qmv in Ubuntu 22.04?

QMV (Quick Move) is a convenient utility that allows the renaming of directories via a text editor. QMV is not pre-installed in Ubuntu 22.04. Qmv is part of the “renameutils” package. To install “Qmv”, first update system repositories by executing the following command:


Then, execute the following command to install the “qmv” utility:

$ sudo apt install renameutils

The output indicates the successful installation of renameutils. In order to rename the directories: “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”, first, navigate to the “Extra” via cd command and then run the following command:


This launches the default text editor of Ubuntu 22.04, i.e., Nano Text Editor with two columns. The left side column holds the name of the directories. On the other hand, the right-hand side column can be edited to rename these directories:

For example, the below image demonstrates the renaming of “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5” by editing the right-hand side column:

Save the file after editing the right-hand side column by pressing Ctrl+X. Next, verify the renaming process by ls command:

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

How to Rename Multiple Directories via Mmv in Ubuntu 22.04?

The MMV utility enables a user to rename multiple directories. MMV is not pre-installed in Ubuntu 22.04. To install “MMV”, first update system repositories by executing the following command:


Then, execute the following command to install the “mmv” utility:


The above output indicates the successful installation of the “mmv” utility. In order to rename the directories: “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”, first, navigate to the “Extra” directory that holds the directories via cd command and run the following command:

$ cd Extra
$ mmv -r ‘*Directory*’ ‘#1Folder#2’

Where the “r” flag represents the renaming operation.

 

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

How to Rename Multiple Directories via Find in Ubuntu 22.04?

The find is used to search for directories. The find command can be combined with the rename and mv (move) utility to search and rename directories as demonstrated in the following sections:

How to Rename Multiple Directories by Combination of Find and Rename Utility in Ubuntu 22.04?

To rename multiple directories having “Directory” in their name by a combination of find and rename utilities, execute the following command:

$ find . -type d -name ‘*’ | rename ‘s\Directory\Folder\’

Where:

  • .: current path
  • d: Directory Flag
  • s/Directory/Folder/: substitute expression

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

How to Rename Multiple Directories by Combination of Find and MV Command in Ubuntu 22.04?

To rename multiple directories having “Directory” in their name by a combination of find and mv command, execute the following command:

$ find . -type d -name ‘*Directory*’ -exec bash -c ‘mv “$1” “$(echo “$1” | sed “s/Directory*/Folder/g”)”‘ _ {} \;

Where:

  • .: current path
  • d: Directory Flag
  • exec: execute command flag
  • sed: sed (stream editor) in UNIX performs many functions. In the above command, it finds a “Directory” and replaces it with a “Folder”

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

How to Rename Multiple Directories/Folders via Ubuntu UI?

Ubuntu UI (User Interface) or simply Ubuntu’s default File manager is the simplest way to rename multiple directories. To rename multiple directories via Ubuntu UI, first select the multiple directories with a mouse or a keyboard and then select the “Rename” option from the dropdown menu:

This will open a new window. Select “Find and replace text” as shown below:

For example, if files are to be renamed by bulk from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”. Then, enter “Directory” in the “Existing Text” tab. After that, enter “Folder” in the “Replace With” tab. Finally, press the “Rename” button.

In order to verify, we can access the “Extra” Directory:

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

Additionally, a directory can be renamed by Numbering schemes in Ascending/Descending numbers by selecting the “Renaming using a template” button instead of the “Find and Replace text “ option used in this section.

How to Rename Multiple Directories/Folders via Gprename Utility?

Gprename is an open-source, free-to-use utility used to rename directories. The gprename utility is not pre-installed in Ubuntu 22.04. To install the “Gprename” utility, first, update the system repositories by running the following command:


Then, execute the following command to install “gprename”:

$ sudo apt install gprename

Press “Y” to continue with the installation process:

The output indicates the successful installation of the “gprename” utility. Launch the Gprename GUI tool first, by clicking on the “Applications” button at the bottom left, then type “gprename” in the search bar, and then select the “GPRename” icon.

Navigate to the “Extra” directory that contains all the directories to be renamed. Then select the “Directories” tab followed by selecting all the directories that need to be renamed. Finally, press the “Preview” button:

After the “Preview” button is pressed, the new names can be previewed under the “New Name” column. Press the “Rename” if satisfied by the remaining:

After the “Rename” button is pressed, the directories are renamed, and appear under the directories name column as shown below:

The above output verifies that the directories are successfully renamed from “Directory1”, “Directory2”, “Directory3”, “Directory4”, and “Directory5” to “Folder1”, “Folder2”, “Folder3”, “Folder4”, and “Folder5”.

Additionally, “GPRename” offers multiple directories remaining in many variants, such as case change, Inserting/deleting text from a directory name, inserting numbers in a directory name, etc.

How to Rename Multiple Directories/Folders via Thunar File Manager?

Thunar File Manager is a free-to-use file manager for Linux that contains built-in remaining operations for files and zipped directories. Thunar File Manager utility is not pre-installed in Ubuntu 22.04. To install the “Thunar File Manager”, first update the system repositories by running the following command:


Then, execute the following command to install “Thunar File Manager”:


Press “Y” to continue with the installation:

The output indicates the successful installation of the Thunar File Manager. In order to rename the directories: “Directory1.7z”, “Directory2.7z”, “Directory3.7z”, “Directory4.7z”, and “Directory5.7z” to “Folder1.7z”, “Folder2.7z”, “Folder3.7z”, “Folder4.7z”, and “Folder5.7z”, first, navigate to the “Extra” via cd command and launch the Thunar File Manager by executing the following command:


After that, Press the “+” button in the top left corner:

This will open a new window. First, navigate to the directory, “Extra” which contains the directories that need to be compressed. Then select all the zipped, followed by pressing the “Open” button in the top right corner:

Next, select “Search and Replace”, followed by typing “Directory” in the “Search For” tab and “Folder” in the “Replace With” tab. Finally, press “Rename Files” as shown in the below image:

After the “Rename Files” button is pressed, the zipped directories are renamed as shown below image:

The above output verifies that the directories are successfully renamed from “Directory1.7z”, “Directory2.7z”, “Directory3.7z”, “Directory4.7z”, and “Directory5.7z” to “Folder1.7z”, “Folder2.7z”, “Folder3.7z”, “Folder4.7z”, and “Folder5.7z”.

Additionally, “Thunar File Manager” offers multiple directories remaining in many variants, such as case change, Inserting/deleting text from a directory name, inserting numbers in a directory name, inserting date/time, etc.

Conclusion

Multiple Directories can be renamed in the command line via Rename, QMV, MMV, and Find utilities while Graphically via Ubuntu UI, Gprename, and Thunar File Manager. This article demonstrated the detailed process of renaming multiple directories in Ubuntu 22.04 LTS. A user can choose the utility that best matches their requirements.

Print Friendly, PDF & Email