8

In linux exist the rename command, for rename a set of files with regular expresions.

rename 's/prefix_//' *.jpg

if I search in the cygwin package I find the renameutils package, but this don't install the the rename command, Install qmv and other similars.

How I can install rename in cygwin ?

juanpablo
  • 6,966
  • 11
  • 52
  • 72

4 Answers4

6

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
Ian Mackinnon
  • 5,606
  • 5
  • 29
  • 33
  • I had to use this method since installing it in Cygwin with `apt-cyg` or `sage` says it worked fine, but I still only have the original utility available. – Pysis Apr 11 '18 at 00:08
  • This was the only method That worked for me. – simlev May 10 '19 at 14:25
6

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


Drew Chapin
  • 5,890
  • 11
  • 51
  • 67
  • Definitely helpful, but this doesn't explain how to install or use `rename` in the environment. – jsleuth Aug 01 '16 at 18:04
  • 1
    @jsleuth, How to install it is in the first sentence of my answer. You have to use the cygwin installer and select the `util-linux` package. The original question provides example usage and does not ask how to use it once it is installed. One would have to assume the OP already knows how to use the command. – Drew Chapin Aug 01 '16 at 22:31
  • 1
    I believe it is clear that the OP is looking for the Perl-based `rename`, the one allowing the use of regular expressions. At least, I am. The `rename` from `util-linux` does not accept Perl-like substitutions. – simlev May 10 '19 at 14:02
3

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>
stderr
  • 10,264
  • 2
  • 32
  • 49
  • It seems that `util-linux` provides the more standard `rename` command. The one allowing the use of regular expressions is instead the Perl-based alternative. See [here](https://unix.stackexchange.com/a/275278/265461) for a slightly more datailed distinction. – simlev May 10 '19 at 14:29
0

download from http://gnuwin32.sourceforge.net/packages/util-linux-ng.htm

extract and overwrite

C:\Program Files\Git\mingw64

like this

yongfa365
  • 101
  • Unfortunately, does not work for me: the binary does not do anything. should I be worried that these files are from 2008? – simlev May 10 '19 at 13:51