How to rename multiple folders in Linux using command line

https:‮ual.www//‬tturi.com
How to rename multiple folders in Linux using command line

To rename multiple folders in Linux using the command line, you can use the rename command. This command allows you to rename multiple files or directories using a regular expression.

Here is an example of how to use the rename command to rename multiple folders:

rename 's/old_name/new_name/' *

This command will rename all files and directories in the current directory that have the name old_name to new_name. The * at the end of the command tells rename to operate on all files and directories in the current directory.

You can also specify a specific directory or directories to operate on, like this:

rename 's/old_name/new_name/' /path/to/directory/*

This command will rename all files and directories in the specified directory that have the name old_name to new_name.

Keep in mind that the rename command uses regular expressions to match the names of the files or directories to be renamed. The example above uses the s/old_name/new_name/ regular expression, which searches for the string old_name and replaces it with new_name.

You can use different regular expressions to match and rename different types of files or directories. For example, to rename only directories that start with old_name, you can use the following command:

rename 's/^old_name/new_name/' *

This will rename all directories in the current directory that start with old_name to new_name, while leaving other files and directories unchanged.

It's always a good idea to test the rename command on a small number of files or directories before renaming a large number of files or directories. This will allow you to make sure that the command is working as expected and that you are not inadvertently renaming any important files or directories.

Created Time:2017-10-28 21:39:07  Author:lautturi