Skip to content

Invalid result with capture variables #33

@gdommergue

Description

@gdommergue

I have the following files in my folder:

pic_F01P01.jpg
pic_F01P02.jpg
pic_F01P03.jpg

I want to obtain:

F01P01.jpg
F01P02.jpg
F01P03.jpg

I was expecting this command to work, but it's not:

brename -p ".*F(\d\d)P(\d\d).*\.jpg" -r 'F$1P$2.jpg' -d
Searching for paths to rename...

  [OK] pic_F01P01.jpg -> F01.jpg
  [OK] pic_F01P02.jpg -> F02.jpg
  [OK] pic_F01P03.jpg -> F03.jpg

3 path(s) to be renamed

If i add a non alpha character to separate the $1 and the P, it works:

brename -p ".*F(\d\d)P(\d\d).*\.jpg" -r 'F$1-P$2.jpg' -d
Searching for paths to rename...

  [OK] pic_F01P01.jpg -> F01-P01.jpg
  [OK] pic_F01P02.jpg -> F01-P02.jpg
  [OK] pic_F01P03.jpg -> F01-P03.jpg

3 path(s) to be renamed

Exact same thing happens if i use -r "F\$1P\$2.jpg"
I'm on Ubuntu 22.04.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions