I usually rename files and directories with the mv command. I'm reading a book on bash shell that mentions the rename command. When I executed man rename a man page was shown. However, when I entered rename on bash shell, it reported:

-bash: rename: command not found

I did some research and discovered that you can install the rename command with Homebrew.

  • Is there any good reason not to install it with Homebrew?

  • Is there anything you can do with the rename command that you can't do with the mv command?

I'm also curious to know if there is a known explanation for why the rename command doesn't exist in the first place. And why is there a man page for a command that does not exist?

  • 1
    After some more searching, I discovered that the reason there is a man page is because it is documenting a BSD system call, not the command. My question asks about installing this utility with homebrew, so it is applicable to the mac.
    – StevieD
    Aug 21, 2018 at 3:15

3 Answers 3


In the default install of macOS, rename man page is available in the section 2. As you can notice from the man page, rename is not a command but a BSD system call.

The Homebrew formula named rename is a Perl script. You should be fine with installing it. In-fact it can give you much more flexibility than plain mv command.

After you have installed rename utility via Homebrew, running man rename will show the man page for the installed utility and not the BSD system call.

I'm also curious to know if there is a known explanation for why the command does not exist in the first place.

rename is not a standard Unix command.

And why is there a man page for a command that does not exist?

As mentioned above, the man page present refers to the system call by the same name.

  • Just saw your answer after installing it with homebrew. Now man rename bring up documentation for the "User Contributed Perl Documentation" for the utility.
    – StevieD
    Aug 21, 2018 at 3:17

With rename command you can search and replace string in multiple files in simply way:

rename 's/oldstring/newtext/' file00*

It's really useful. With mv you cannot do the same. Unless you get loop to work:

for file in file00*; do new=${file/oldstring/newtext}; mv —- "$file" "$new"; done
  • 2
    I found the zmv in the "new" default Zsh shell to do most of the filename rename tasks I need. Don't even need brew install rename. Just "autoload -U zmv" and you are ready. "zmv -n '(*/)().js' '$1$2.ts'" will preview what it is about to do, and remove -n to get it done.
    – eplt
    Oct 22, 2021 at 2:25

You can install using brew https://brewinstall.org/Install-rename-on-Mac-with-Brew/

Hope this solves your problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .