2

I have about 80 of these files in my directory.

-rw-rwxr--+ 1 vagrant vagrant  38122 Nov 13 12:19 CRMPicco RFC16 Women's 80.jpg
-rw-rwxr--+ 1 vagrant vagrant 101286 Nov 13 12:19 CRMPicco RFC16 Women's 8.jpg
-rw-rwxr--+ 1 vagrant vagrant  30110 Nov 13 12:19 CRMPicco RFC16 Women's 9.jpg

I am running CentOS 7.0 and have rename installed.

[vagrant@crmpicco /var/www/crmpicco/web/php/upload/10111/165-190]# which rename
/usr/bin/rename

cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)

However the following doesn't rename any files for me. I've tried a bunch of different ways seen on SuperUser, but none of them seem to work.

[vagrant@crmpicco /var/www/crmpicco/web/php/upload/10111/165-190]# rename s/Women/W/ *.jpg

Am I doing something stoopid?

2
  • What do you want to rename the files to?
    – Wilf
    Commented Nov 13, 2015 at 16:57
  • @Wilf In my example above I wanted to start by renaming Women to W. Is my syntax wrong?
    – crmpicco
    Commented Nov 13, 2015 at 17:01

1 Answer 1

5

That's not how rename works. The util-linux "rename" command only accepts two static strings (basic search and replace):

rename "Women" "W" *.jpg

For the Perl-like regex syntax, you will need rename.pl aka perl-rename. It's not packaged for CentOS, but you can obtain it directly from CPAN as the File::Rename module

Some distros such as Debian will swap the names, so that rename is from Perl and rename.ul from util-linux, I guess that's where the confusion comes from.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .