install rename command in cygwin

6

2

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

Posted 2014-02-24T20:22:33.027

Reputation: 5 216

Answers

5

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

Posted 2014-02-24T20:22:33.027

Reputation: 4 839

Definitely helpful, but this doesn't explain how to install or use rename in the environment. – jsleuth – 2016-08-01T18:04:36.733

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 – 2016-08-01T22:31:30.860

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 – 2019-05-10T14:02:18.250

3

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

Posted 2014-02-24T20:22:33.027

Reputation: 3 919

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 – 2018-04-11T00:08:09.783

This was the only method That worked for me. – simlev – 2019-05-10T14:25:38.977

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

Posted 2014-02-24T20:22:33.027

Reputation: 9 300

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 for a slightly more datailed distinction.

– simlev – 2019-05-10T14:29:53.977

0

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

extract and overwrite

C:\Program Files\Git\mingw64

like this

yongfa365

Posted 2014-02-24T20:22:33.027

Reputation: 101

Unfortunately, does not work for me: the binary does not do anything. should I be worried that these files are from 2008? – simlev – 2019-05-10T13:51:17.553