Assistance Needed to Rename Files More Efficiently

Thank you again @ohrenkino, and everyone else for your advice. Let's leave it at that.

Could you give us exact examples how the filenames look at the moment.

1-Disc Album "A"
01. Win Or Lose.mp3
02. Dipping.mp3
03. Water Runs Deep.mp3

3-Disc Album "B"
CD1

1-01. Peoples Need.mp3
1-02. Lovely Dance.mp3
1-03. Animal Stares.mp3
CD2
2-10. Zozo Hut.mp3
2-10. Vivid Image.mp3
2-10. Endless Stars.mp3
CD3
3-20. Dreams.mp3
3-20. Fools Around.mp3
3-20. Birds Flying.mp3


Hello again, Everyone.

Planning the still daunting job ahead, I was contemplating another avenue which could possibly be explored. Hence, I simply have to pose another question to our adept code-writers. Namely:

Since the filenames themselves are consistently named, is it perhaps executable to apply the filename itself in building a format string with which to insert the %artist% into the filename, instead of applying the current dodgy %discnumber%?

Thank you for your input.

Now I am puzzled: in the initial post you wanted to unify the filenames and now you say that

so there is no real need to rename the files?
In general: if the data in the filenames is better than the data in the tags, import the data from the filenames to get some structure that could be used much easier in the future.

I asked this to see if the filenames themselves contain information that can be extracted for tagging.

At first glance, it appears that the only thing missing from the filename is the ARTIST tag.

Furthermore, based on your previous statements, the contents of the DISCNUMBER tag field are correct and consistent. Only the entries for albums with just one disc are inconsistent, sometimes containing no information, sometimes just a simple number without the total number of discs.

Changing the filenames alone isn't a major problem, but it's still recommended to keep the tags consistent and rename the filename based on the tags instead of only fiddling with the filename

To do this efficiently, you should simply apply a filter. It's noticeable that your filenames without multiple discs don't have a minus sign at the beginning of the filename.

A filter for albums without multiple discs could therefore look like this:
NOT %_filename% MATCHES ^\d-

This filters for filenames that don't begin with a number followed by a minus sign.

For these files, you then correct the DISCNUMBER field to 1/1 (as @Lyrislover recommends) or delete it entirely.

If you've decided to delete, you can use @Ohrenkino's suggestion:
[%discnumber%-]%track%. %artist% - %title%
to rename all files in one go.

If you've chosen "1/1", you can proceed by filtering separately:

NOT %_filename% MATCHES ^\d-
%track%. %artist% - %title%

%_filename% MATCHES ^\d-
%discnumber-%track%. %artist% - %title%

It's best to use the Tag-->Filename converter, as it includes an instant preview of the result.
As always For testing in such mass campaigns, the advice is:
First try it out on copies of the originals.

Thank you for replying @ohrenkino.

Initially, I renamed the files as they are shown in my posts here. I am satisfied with the result just like that — and that includes the display of the %discnumber% — because I planned in that manner using the tag data at my disposal at the time. (I wanted to keep the filenames short to begin with).

One-Disc album: %track%. - %title

Multiple-disc album: %discnumber%-%track%. %title%

However, as time passed, I discovered that the %artist% — now absent from the filename — is beneficial to my operations. So much so that I am willing to put in the time, again, to mould the database accordingly. Thus, I want to add the %artist% to the current filename, and was hoping to achieve that goal as painless as is possible.

One-Disc album: %track%. %artist% - %title

Multiple-disc album: %discnumber%-%track%. %artist% - %title%

Just to complete my answer above:
If you really want to fiddle with the Filename only and not take the chance to make your tags consistent:

C̶o̶n̶v̶e̶r̶t̶e̶r̶ ̶F̶i̶l̶e̶n̶a̶m̶e̶-̶>̶F̶i̶l̶e̶n̶a̶m̶e̶
̶O̶l̶d̶ ̶F̶i̶l̶e̶n̶a̶m̶e̶ ̶P̶a̶t̶t̶e̶r̶n̶:̶
̶̶%̶1̶.̶ ̶%̶2̶̶
̶
̶N̶e̶w̶ ̶F̶i̶l̶e̶n̶a̶m̶e̶ ̶P̶a̶t̶t̶e̶r̶n̶:̶
̶̶%̶1̶.̶ ̶%̶a̶r̶t̶i̶s̶t̶%̶%̶2̶̶

Lösung war falsch.

Thank you, too @poster

Yes

Correct. It is only the one-disc entries that display either "blank" or "1".

As for the rest, I am digesting and will test it in due course. From what I gather, a 2-step operation is inevitable.


Thanks for this, too.

@poster:

I ran a quick test: it did not insert the %artist% at all?

Is it possible to build an effective format string (to insert the %artist% into the current filename) around the distinction that the first few characters of the filenames (say 4) either contain a "-" (dash), or not?

Sorry. That's my mistake. I almost never use the Filename->Filename converter and therefore apparently remembered a feature that doesn't exist.

Basically, you just need to filter by both variants, as I described.

For single-disk albums, you can use the Tag->Filename converter:
%track%. %artist% - %title%

and for multi-disc albums:
%discnumber%-%track%. %artist% - %title%

this is not exactly what you are looking for but i made this to use metadata to move my audiobooks and create folders if any books are added ti the folder it watches
maybe you can use ai to convert it for renaming

Try Convert>Tag - Tag for _FILENAME
Format string: $regexp(%_filename%,(.*?)\. (.*),$1. %artist% $2)

Thank you @ohrenkino! Again, you saved the day for me. I tested your proposal on a good mixture of albums produced by the same performing artist. With one small edit to your format string, it worked flawlessly:

$regexp(%_filename%,(.*?)\. (.*),$1. %artist% - $2)

I am going ahead now to apply your solution.

Thank you, for sharing your undoubted expertise with us.

Inevitably, while taking a deep dive, new variables crop up. I've already discovered a niggling one and wonder if there's a solution—perhaps by tweaking the current syntax below, provided by @ohrenkino:

Tag - Tag > _FILENAME > Format string
$regexp(%_filename%,(.*?)\. (.*?),$1. %artist% - $2)

The issue is that while the old file naming convention was standardised, a small number of tracks don't precisely conform to it. In some cases, the %artist% tag has already been injected into the filename. Could the syntax above be amended to auto-skip those filenames and avoid duplicating the artist name?

Thank you in advance for looking into this.

You could try
Format string: $regexp($replace(%_filename%,%artist%,),(.*?)\.\s*(.*),$1. %artist% - $2)

Thank you @ohrenkino.

Having run a quick test one one filename, I found that it does appear to skip the artist name, but it now insert an extra dash and space after the artist name: for e.g.

01. André Kos - - My Favorite Things

You would have to add all that what makes up the artist in your opinion to the replacement string, e.g.
$replace(%_filename%,%artist%,)
becomes
$replace(%_filename%,%artist% -,)