Linux provides different commands in order to rename folders. The folder can be also called a directory which is used interchangeably with the term folder
. In this tutorial, we examine how to rename a folder which is a very similar operation to moving a folder. We will only examine the renaming folder command line operations.
Rename Folder with mv Command
The mv
command is created to move files and folders. We can use the mv command in order to rename folders in Linux. The old or original name is provided as the first parameter and the new name is provided as the second parameter. In the following example, we rename “backups” as “db”.
$ mv -R /home/ismail/backups /home/ismail/db
Rename Folder with rename Command
The rename
is the original command in order to rename a folder. We can provide the folder name patterns to rename them. In the following example, we rename the folders whose names start with “backup” into the “db”.
$ rename "s/^backup/db/" *
Rename Folder with gvfs-move Command
The gvfs-move
is a similar command to the mv
command. The gvfs-move command is created for file share or network share-related operations but it can be also used for local operations.
$ gvfs-move /home/ismail/backups /home/ismail/db
Rename Folder with gvfs-rename Command
The gvfs-rename
is very similar to the mv command and can be used like the one below in order to rename the folder.
$ gvfs-rename /home/ismail/backups /home/ismail/db