Regex batch rename help

What am I doing wrong?

My file names are of the form

name-yyyy

where yyyy is the year, eg. 2005

and I want to change this to:

name (yyyy)

I tried the batch rename script with the source pattern:

^(.*)-(\d{4})

and destination pattern:

$1 ($2)

but it does not do anything.

Do you mean you want to put the date in parentheses? I would not suggest you do that. To keep general conformity I would suggest you only use hyphens, underscores, spaces, and dots in filenames - no other punctation.

$1 ($2)

That is the incorrect form. It’s BSD sed under the hood.
Use this source with an explicit range…

And again, I’m not advocating parens, but you can use this destination pattern…

2 Likes

Just came across this today when I was wondering “how do I prefix this set of items?”, and it was invaluable, thank you !!

1 Like

You’re welcome.
Also note you can do file renaming in Tools > Batch Process as well.

Nice, this is actually better, I missed the Change Name option (or didn’t see the “Name” placeholder there).