Rename command behaviour

When I was running Ubuntu MATE 20.04, I installed a program called 'rename'.
If I had a directory called Mr. Smith, and files in it called ...
Mr. Smith - Issue 1.pdf
Mr. Smith - Issue 2.pdf
Mr. Smith - Issue 3.pdf

... and I wanted to get rid of 'Mr. Smith - '

I would call rename like this: rename 'Mr. Smith - Issue 1.pdf' '' *.pdf

I recently installed Ubuntu MATE 22.04 LTS and installed 'rename'

When I try that command, I get an error:
Bareword "Mr" not allowed while "strict subs" in use at line 1.

Doing a 'man rename' makes it obvious that the rename I used to use is not the same one I have now.

Any idea how or where I can get the rename I used to have?

sudo apt install rename

$ touch "Mr.Smith - issue 1.pdf"
$ touch "Mr.Smith - issue 2.pdf"
$ touch "Mr.Smith - issue 3.pdf"

$ rename -V
/usr/bin/rename using File::Rename version 1.30, File::Rename::Options version 1.10

$ rename 's/Mr.Smith - //' *.pdf

$ ls
'issue 1.pdf'  'issue 2.pdf'   'issue 3.pdf'   
$
3 Likes

Oops, I see I got the syntax of the rename I had when running 20.04 wrong.

Given the files in a directory as in my post, the syntax:

rename 'Mr. Smith - ' '' *.pdf

would result in the files in the directory being renamed to

Issue 1.pdf
Issue 2.pdf
Issue 3.pdf

To clarify, the first argument would select the part of the filename to be changed, and the second, what it should be changed to (in this case, to nothing).

This is a bit embarrassing. It turns out that I was using a Regina-rexx script I wrote to rename multiple files. I had forgotten that I wrote it, so I downloaded rename, and of course it worked differently.
Appologies!

3 Likes