I would like to change filenames of my flac files using the following string:
$num(%track%,2) - %artist% - %title%
but, to avoid having too long filenames, I would like to replace the complete artist name (for example Wolfgang Amadeus Mozart) with the last name (Mozart). And I would like this to happen automatically independently of the specific artist considered
Is this possible in a simple way?
$num(%track%,2) - $regexp(%artist%,.* (.*?),$1) - %title%
You could save additional space if you reduced the separator from "space-hyphen-space" to just "underscore"
And how do you distinguish between
Johann Christoph Bach
Johann Sebastian Bach
Johann Ludwig Bach
Carl Philipp Emanuel Bach
if all of them becomes just "Bach"?
Thanks, this does work when %artist% is in the form "First name last name", I will try to figure out if I can generalize it to other situations (that is for example "Last Name, First Name". If you can point me to documentation about managing regexp I would be very grateful for it.
What about the help
Usually - regular expressions describe a pattern. And if the pattern is a different one, it is hard to "generalize" it.
I am not going to batch rename all files, but only folder by folder, and fortunately I have no occurrence of folders containing more than one member of the Bach family as artist.
Of course, the ideal solution would be to parse %artist% and get the initials of first names and then output them as J.S. Bach, J.C. Bach, and so on, but I guess this is quite difficult to achieve.
Indeed, it is hard. After investigating a while, I have limited myself to this "workaround".
First, I have created a new group of actions of the type replace with regular expression; each action is for a single artist and it parse the artist field looking for a specific word; if found, it replaces with the string desided. Example:
Regular expression: ^.bach.*
Replaces matches with: J. S. Bach
Then, I have converted the filenames using $num(%track%,2) - %artist% - %title%
This is however not the ideal solution to my problem for two reasons:
- it modifies the artist field, while I would like to keep it untouched and to modify only the filenames.
- the regular expression above does not distinguishes the members of the Bach family.
I don't know if this workaround can be improved, any suggestion is welcome.
Ok, I have found a very convoluted way to prevent this: first convert tag-tag copying %artist% into %comment%; then apply actions above to field COMMENT; at the end, convert filenames with $num(%track%,2) - %comment% - %title%
In this way I lose original %comment% content which is however not very informative in my situation.
You can create a custom tag for any name you like. In this case perhaps something like LastName would do for clarity? You can then use a Format action to take the last word from the current Artist field. Then your filename update can use this new field. No change to your actual Artist or Comment fields necessary.
I think that this is becoming far more complicated than necessary. If you use a custom field, you have to make sure that this custom field exists to get a shortened filename.
So, IMHO, once you get ARTIST, ALBUM and TRACK in the filename, the filename should be unique enough to comply with the file system's requirements.
And if you now want to get a hint what the file is about, I would suggest a shortened TITLE created with something like ($left(%title%,20).
Of if you want to get a standard filename length, you could just as well use this
$left($num(%track%,2) - %artist% - %title%,80)
when creating the filename..
And quite openly: the filename is no decent transport medium for tag information. The only requirement is: be unique.
Detailed information should be retrieved from the metadata.
I have a different approach for my classical music files than with my other music files, mainly because I want to be able to build directory structures and filenames.
From stretch on I create the shortended field COMPOSERSORT and fill it like this:
while my composerfield still looks like:
Wolfgang Amadeus Mozart
Ludwig van Beethoven
Anyway you have to be pragmatic. There is no best way to tag classical music and make it compatible with common player-software.
The following regular expression reduce the first and second word to a single character and leave the third word untouched. To be clear: This only works with 3-word-artists (and not for 2-word-artists like "Richard Strauss" or 4-word-artists like "Carl Philipp Emanuel Bach").
You have to filter/select your 3-word-artists before you use this regular expression:
Of course you can play around the single character output with $1 and $2:
You can set a space after the first dot like
$1. $2. or remove the space at the end like
$1.$2. to get results like
J.S. Bach or
J. S. Bach or
Just for the record:
You can also apply such a regular expression to your filename using _FILENAME as Field:
or you choose ALT + 1:
Thanks a lot to everybody. Until yesterday I didn't know anything about mp3tag and now I am trying to learn about it as fast as possible. I will keep into account all of your suggestions and try to find the solution which is most tailored to my needs, even if, as poster wrote, there is no best way to achieve perfect tagging for classical music.
Only your library can be perfect for you. Tag it as you need it to work with your preferences and player requirements.