who can help with a special regular expression?


#1

Hi,

I often have the problem that in a track file name like

Flute Sonata B-Dur

an "in" is missing, so it will read

Flute Sonata in B-Dur

Only problem is that it can be A-Dur through H-Dur and a-moll through h-moll and it should exclude the strings which already have an "in " in front of the Dur/moll - furthermore there are the As, Des, Fis, Cis etc values in front of the -Dur and -moll possible

Who can help?

thanks


#2

You may deepen your knowledge on the key signatures.
http://en.wikipedia.org/wiki/Circle_of_fifths
http://de.wikipedia.org/wiki/Quintenzirkel

I understand your request this way.

You want to manipulate a given filename:
"Flute Sonata B-Dur"

You want to insert the word "in" before a word which is a key signature to get the filename:
"Flute Sonata in B-Dur"

You want not to change filenames which are already have the word "in" before a key signature.

Use Mp3tag list view. Press [F3] to open the Filter dialog.
There might exist several expressions to filter your file base in order to see only those files, which do not have the word "in" before a key signature.

First see what files have already the word "in" before a key signature:
%_FILENAME% MATCHES "^(.+) in ((?:.+?)-(?:moll|Dur))(.*)$"

To see all files which do not have the word "in" before a key signature:
NOT %_FILENAME% MATCHES "^(.+) in ((?:.+?)-(?:moll|Dur))(.*)$"

There might be other files shown which are not of interest, so you have to do some refinement on the filter expression.
Examples:
(("%_FILENAME%" HAS "-moll") OR ("%_FILENAME%" HAS "-Dur")) AND NOT ("%_FILENAME%" HAS " in ")

NOT %_FILENAME% MATCHES "^(.+) in ((?:.+?)-(?:moll|Dur))(.*)$" AND (("%_FILENAME%" HAS "-moll") OR ("%_FILENAME%" HAS "-Dur"))

Set the filter to see only files, which do not have the word "in" before a key signature.

Use an action "Replace with Regular Expression"
Field: %_FILENAME%
Regular expression: ^(.+)\s((?:.+?)-(?:moll|Dur))(.*)$
Replace matches with: $1 in $2$3
Case-sensitive comparison: yes

Alternative:
Action "Format value"
Field: %_FILENAME%
Formatstring: $regexp(%_FILENAME%,'(?-i)^(.+)\s((?:.+?)-(?:moll|Dur))(.*)$','$1 in $2$3')

Ready.

DD.20100919.0900.CEST


#3

DetlevD,

many thanks for your kind help!
Very much appreciated

And you are right, I didn't know certain details of the key signatures
Your hint is very valuable for me...
Every day learning something new!

:slight_smile: