Replacing in Title tags


#1

Hi I'd like to learn how to Replace the variable length of my Title tags

From this:
Mozart P Con #6 In B Flat, K 238 - 3. Rondeau
Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 1. Allegro
Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 2. Adagio
Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 3. Rondeau
Mozart P Con #8 In C, K 246, "Lützow" - 1. Allegro Aperto

To This:
Mozart P Con #6 - 3
Mozart P Con #7 - 1
Mozart P Con #7 - 2
Mozart P Con #7 - 3
Mozart P Con #8 - 1

I imagine this is an action but if it is multiple Tag-tag that would be great - maybe even more clear? Thanks


#2

Using an action like below will do your task by using tag-tag :mt_ttt: either.

Begin Action Group _Script Test#TEST

Action #1 Actiontype 5: Format value Field ______: TITLE Formatstring: $regexp(%title%,'^(.{13,15}#\d+\s+)[^-]+(-\s+\d+).+','$1$2')

End Action Group _Script Test#TEST (1 Action)

Of example file Mozart P Con #6 In B Flat, K 238 - 3. Rondeau the only variable is between the #6 and 3 and at the end where there is the same problem. This is dealt with [^-]+ which finds anything but a - any number of times after #6 and .+ which takes care of that problem at the end after 3.

Please have a look at the screen-shot of how the regexp works.


Any Q. just ask.



#3

I wouldn't expect this character count to work well, except in the very narrow context of the example strings. It shouldn't be necessary if you always have '#\d+', or even just '\d+'.


#4

If that is the case MichaelZulu. Change the {13,15} to +


#5

Thank you Steve and JJ, used the + over {13,15} and worked great. RegexBuddy btw looks good multi text file editor? I have been using TexTreplacer.

Michael


#6

Your example strings have varying length and look like as they are following always the same pattern.
%TMP1% #%TMP2% %DUMMY% - %TMP3%. %DUMMY%
There are fix points in each string, so you can use an action "Guess values" to split the original title string into parts and save the valueable parts into temporary tag-fields.
Then assemble the new title string from the temporary tag-fields and put it in a temporary tag-field too.
If the results are looking good, then overwrite the tag-field TITLE with the newly calculated title value.
Afterwards remove the temporary helper tag-fields.

Here is an action group which has all steps included.

Begin Action Group Test_2012#20121114.MichaelZulu

Action #1
Actiontype 7: Import tag fields (guess values)
Source format __: %TITLE%
Guessing pattern: %TMP1% #%TMP2% %DUMMY% - %TMP3%. %DUMMY%

Action #2
Actiontype 5: Format value
Field ______: TMP4
Formatstring: %TMP1% #%TMP2% - %TMP3%

Action #3
Actiontype 5: Format value
Field ______: TITLE
Formatstring: %TMP4%

Action #4
Actiontype 9: Remove fields
Fields to remove (semicolon separated): TMP1;TMP2;TMP3;TMP4

End Action Group Test_2012#20121114.MichaelZulu (4 Actions)

You can also solve this task using the converter "Tag - Tag" and a regular expression function.

Convert | Tag - Tag | ALT+5

Select format string

Field:
TITLE

Format string:

$regexp(%TITLE%,'^(.+#\d+)\s.+(\s-\s\d+).+$','$1$2')

Preview
"Mozart P Con #6 In B Flat, K 238 - 3. Rondeau" ->
"Mozart P Con #6 - 3"

"Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 1. Allegro" ->
"Mozart P Con #7 - 1"

"Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 2. Adagio" ->
"Mozart P Con #7 - 2"

"Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 3. Rondeau" ->
"Mozart P Con #7 - 3"

"Mozart P Con #8 In C, K 246, "Lützow" - 1. Allegro Aperto" ->
"Mozart P Con #8 - 1"

DD.20121114.0840.CET


Tag _FROM_ Tag -- Import tags from tags
#7

Check this out. RegexBuddy Demo


#8

Your example strings have vayring length and look like as they are following always the same pattern.

%TMP1% #%TMP2% %DUMMY% - %TMP3%. %DUMMY%

I wanted to see that thanks