Search code examples
regexunixcygwinrename

rename -n option seems not available under cygwin


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.


Solution

  • 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.