rename: command not found

The rename command is a utility in Unix-like operating systems that allows you to rename multiple files at once. It is used to change the names of files and directories, and it provides a powerful and flexible way to manipulate file names.

The rename command can also be used with regular expressions, allowing you to match more complex patterns in file names and perform more sophisticated transformations. This makes it an extremely useful tool for bulk renaming of files, especially in scenarios where you need to rename a large number of files or where the names of the files have a specific pattern.

If you encounter the below error while running the command rename:

rename: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install util-linux
Ubuntu apt-get install util-linux
Alpine apk add util-linux
Arch Linux pacman -S util-linux
Kali Linux apt-get install util-linux
CentOS yum install util-linux
Fedora dnf install util-linux
OS X brew install rename
Raspbian apt-get install util-linux

rename Command Examples

1. Rename files using simple substitutions (substitute ‘foo’ with ‘bar’ wherever found):

# rename foo bar *

2. Dry-run – display which renames would occur without performing them:

# rename -vn foo bar *

3. Do not overwrite existing files:

# rename -o foo bar *

4. Change file extensions:

# rename .ext .bak *.ext

5. Prepend “foo” to all filenames in the current directory:

# rename '' 'foo' *

6. Rename a group of increasingly numbered files zero-padding the numbers up to 3 digits:

# rename foo foo00 foo? && rename foo foo0 foo??
Related Post