I thought I had my roman numeral problem solved, but only with single digits

Hello again,

Sorry to be asking for so much help but I have tired to resolve things myself for hours and still fail. :sob:

Anyhow, I have read many threads on converting Arab to Roman and Roman to Arab, including Converting roman to arabic number and vice versa

From the fields %movement% and %movementtotal% I want to convert Arab numerals to Roman numbers and vice-versa. I create the names of my titles from the work & movement fields (%title% = %work%: %movement%. %movement name%) and would keep everything in roman up to 21 movements (a rule I read somewhere), but I found out that iTunes does not take roman numerals for their respective fields, so if I do not use arabic numbers, the movement number or total do not register.

For converting from roman to arab, I tried the following:
Field: Movement


but any number over 9 created problems, because they were made up of the values before (e.g, "11" came back as "II" because it was made up of two "1"s. I could add leading zeros, which would solve the problem, but m4a does not allow leading zeros. I did find I could format the column using $num(%movement%,2), which would theoretically solve the problem of Arab to Roman, albeit not very elegantly, but it would not solve the problem that occurs when converting Roman back to Arab numbers.

When trying the same method to convert Arab numerals to Roman using


a value such a "II", will return "11" instead of "2".

There has to be a way to use scripts to either make each value discrete, where 1 and 11 are treated differently. I think it would involve some $iflonger function but I just can't figure it out. :man_facepalming: I have been trying a long time and thought maybe someone with much greater knowledge of Regular Expressions can help.

It would be greatly appreciated!! :clap:

I think that $replace() processes the pairs from the beginning to the end.
So if you start with the longest Roman number and work your way down to the shortest, it should work.
And if nothing helps, split the action into so many further actions, that you end up with unique strings after each process step.

1 Like

Thanks ohrenkino!

Unfortunately the first suggestion did not work, but the second did, though it was time consuming! At least I only have to do the work once. I will post a link to the Actions once I verify everything is working.

Using WORD I was able to replace values in the .mta files to make the creation of an action for each instance: Movement Arab to Roman, Movement Roman to Arab, Movementtotal Arab to Roman, Movementtotal Roman to Arab.

Thanks again for your help. I was going crazy trying to figure this out.

OK, so I got things working and want to share my not-so-elegant scripts. Maybe they will be of use to someone in the future. If I should post them elsewhere so they could easily be found, please let me know. I did not want to put it in the REG Ex thread because it is not a regular expression.

Movement Roman to Arabic.mta (942 Bytes) Movement Total Roman to Arabic.mta (1.0 KB) Movement Arabic to Roman.mta (939 Bytes) Movement Total Arabic to Roman.mta (1.0 KB)