9

I have a bunch of files with names like

... (Karton 1).jpeg

and would like to rename them recursively to:

... (brauner Karton).jpeg

I tried the following commands, which didn't work:

rename -v 's/Karton 1/brauner Karton/g' *
rename -v 's/Karton 1/brauner Karton/g' *.jpeg

According to a lot of examples this shouldn't be that hard. What am I doing wrong?

Aditional info: "Karton 1" would be "[B/b]ox 1" in English.

guntbert
  • 13,134
Markus
  • 1,585
  • 2
    What exactly happened? Was there any output? You may be using the wrong rename... You don't need to escape spaces in regex, btw. Also, please show your real filenames - do not add quotes, . characters etc that are not really there! – Zanna Apr 14 '18 at 12:48
  • Version is 2.31.1 (util-linux). – Markus Apr 14 '18 at 12:58
  • Try rename -n ... first. What does it show? – PerlDuck Apr 14 '18 at 13:02
  • No output. Also not with rename -n -v – Markus Apr 14 '18 at 13:11
  • if no output, means you don't have a file that match with what you are trying to rename. Likely you already rename it before too. – αғsнιη Apr 14 '18 at 13:12
  • 2
    rename.ul is the wrong rename for this syntax. You need Perl rename (file-rename). Are you using Ubuntu? – Zanna Apr 14 '18 at 13:14

1 Answers1

14

There are several versions of the rename command. Use rename --version to determine which you have, they use different syntax.

$ rename --version
/usr/bin/rename using File::Rename version 0.20
$ rename 's/\.jpeg$/.jpg/' *

$ rename --version
rename from util-linux 2.30.2
$ rename .jpeg .jpg *
Zanna
  • 70,465
rtaft
  • 1,825
  • I think you and the OP are talking about different utilities. And wonder which one he actually has. – PerlDuck Apr 14 '18 at 13:07
  • 1
    He's got the one I have. Mine is util-linux 2.30.2, I ran into this issue a year ago and couldn't figure out how to get rename to work again...if I had only looked at the man page. – rtaft Apr 14 '18 at 13:11
  • 1
    Ok. Because there's also one with his syntax. – PerlDuck Apr 14 '18 at 13:12
  • I know, I used to use it, trying to figure out when/why that changed. – rtaft Apr 14 '18 at 13:13