install rename command in cygwin

rename is provided by the util-linux package which can be found under the following categories in the Cygwin installer.

  • System
  • Text
  • Utils

If you would like to find out which package provides a particular executable, you can use the cygcheck command which comes with Cygwin by default.

$ cygcheck -p 'rename\.exe'
Found 6 matches for rename\.exe
x86_64/gvfs/gvfs-1.16.3-1
x86_64/gvfs/gvfs-1.16.4-1
x86_64/gvfs-debuginfo/gvfs-debuginfo-1.16.3-1
x86_64/gvfs-debuginfo/gvfs-debuginfo-1.16.4-1
x86_64/util-linux/util-linux-2.21.2-1
x86_64/util-linux-debuginfo/util-linux-debuginfo-2.21.2-1



The program with regular expression functionality that you require is a Perl script, sometimes called Perl Rename, or prename. It is usually distributed with Perl and is a different program to the rename provided by util-linux.

One way to enable it on Cygwin is to download it from GitHub. This just requires that you have the Perl Cygwin package installed.

mkdir -p ~/bin
wget https://raw.githubusercontent.com/subogero/rename/master/rename
mv rename ~/bin
chmod +x ~/bin/rename
PATH=~/bin:$PATH    # Add this to your ~/.bashrc to make it permanent
which rename

By default, cygwin does not come with rename ability. The package util-linux is required.

Cygwin’s rename command renames files if you tell it the exact name of your target file. This is the same as the mv command.

Syntax:

mv <filename> <new filename>