How To Rename Directories and Folders In Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-rename-directories-and-folders-in-linux/
PINTEREST
PINTEREST
INSTAGRAM

Renaming or moving directories and folder can be tricky if those directories and folders have some subfolders. Or the destination may have all ready same name folder which will create some error. In this tutorial we will look how to rename and move directories and folders in Linux.

Rename Using Mv Command

The defacto command for rename directories and folders is mv . mv is the short form for the move . We can simply rename by providing the current directory and folder name and destination directory or folder name. Syntax is like below. If the source or current directory folder have content we need to rename by using recursive move. This will only change given directory or folder name but move all sub files and folder.

In this example we will rename directory named backup  into old_backup .

Verbose

While renaming or moving files and folders we may need to get verbose information. Verbose mode will print every move or rename. This will be helpful for recursive option. We will provide -v to enable verbose.

Verbose

Verbose

Overwrite Forcibly If Exists

In some cases there may be existing folder or directory with the new name. We need to confirm the overwrite. But this can be daunting task if there is a lot of them. We can overwrite existing files and folder with -f option automatically. -f means forcibly.

LEARN MORE  Linux Rename Files And Folders With Rename Command With Examples

Prompt For Confirmation Before Overwriting

If we do not want to write existing file forcibly we can confirm for each file rename. In this case we have to use -i like below.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-rename-directories-and-folders-in-linux/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)