How to change the title of tracks with number only

I have an audio book where the tracks have titles like this

Opening Credits
1
2
3
4
5
.
.
.

The numbers represent chapters. So I would like to change the titles of the number-only tracks to

Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5

but keep the tracks with other titles as is.

How can I do this?

Many thanks for any pointers!

Good question! The first thing you’ll need is a query to select just the tracks you’ll want to change. You can try out various queries with beet ls. Something like this could work:

beet ls title::'\d+'

That uses a regular expression query (you can read more in the docs about beets queries).

Then, you want to change the title to include the number. For that, you’ll need a feature that is only available in the latest beets source (see the FAQ for how to install from source) called formatted modify. That feature lets you do something like this:

beet mod title='Chapter $title' title::'\d+'

…to change the title based on the old title.

I hope something in here is helpful!

1 Like

Hey, this looks pretty cool!

So, formatted modify is the feature that I can use (the old) $title in a title modify command, right?

For this I have to install from source – I will try this over the weekend.

Yep, precisely!

1 Like

It works, @adrian! Super thanks for explaining this in detail!