2

I'm trying to rename several files at once with cygwin and would like to use the rename command. I would like to use the -n option ... no action. It feels saver to me because I'm no regex guru.

I found helful sources and they tell me that there should be this option:

-n, --no-act    No Action: show what files would have been renamed.

I am using cygwin and when I show the rename manual the -n option seems not available:

RENAME(1)                                                                           User Commands                                                                           RENAME(1)

NAME
       rename - rename files

SYNOPSIS
       rename [options] expression replacement file...

DESCRIPTION
       rename will rename the specified files by replacing the first occurrence of expression in their name by replacement.

OPTIONS
       -v, --verbose
              Give visual feedback which files where renamed, if any.

       -V, --version
              Display version information and exit.

       -s, --symlink
              Peform rename on symlink target

       -h, --help
              Display help text and exit.

Any advice is appreciated.

elToro
  • 1,003
  • 9
  • 31

1 Answers1

1

On Cygwin rename program comes from util-linux, see the bottom of man rename:

The rename command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.

On some (most?) Linux distributions rename is a short Perl script. If you have Perl installed on your Cygwin installation just copy rename script and run it.

Arkadiusz Drabczyk
  • 11,227
  • 2
  • 25
  • 38
  • Thank you for your answer. I have installed perl on Cygwin. How do I find the perl rename script? – elToro Jul 24 '15 at 10:39
  • no problem, if it works for you please mark it as accepted so that other SE users know it's solved – Arkadiusz Drabczyk Jul 24 '15 at 10:40
  • 1
    You can get it here: https://github.com/subogero/rename/blob/master/rename. From [this answer](http://stackoverflow.com/questions/22577767/get-the-perl-rename-utility-instead-of-the-built-in-rename) – pak Jul 24 '15 at 22:23
  • @elToro You must have edited your comment after I had seen it for the first time. Use `type rename` to learn where `rename` lives on your Linux system or download it from the Internet as explained in the above comment. – Arkadiusz Drabczyk Jul 24 '15 at 22:44