I am working with a collection of music folders that have a catalog id somewhere in the folder name. I want to be able to get that id out of the directory name and save it to the catalog id field, and then later use it in a subsequent action step to add it to the album field in brackets. I am able to create a regex that works to identify the substring, but the same regex doesn't seem to work in this tool.
The position of the substring in the folder name is inconsistent, but the id substring follows this pattern:
K7 followed by numbers and capital letters followed by either a - or ) indicating the end of the id was the previous character
examples:
text text text K7123CD-text text -> K7123CD
text text (K7234EP) text -> K7234EP
text text text-K7456DDD-text -> K7456DDD
The regex I am trying to use for this looks like this:
K7.+?(?=[-)])
I tested that regex against the sample strings above and it found the right substring:
echo "text text text K7123CD-text text" | grep -P 'K7.+?(?=[-)])'
echo 'text text (K7234EP) text' | grep -P 'K7.+?(?=[-)])'
echo 'text text text-K7456DDD-text' | grep -P 'K7.+?(?=[-)])'
In mp3Tag, I tried creating an action like this:
Format value:
Field: CATALOGID
Format string: $regexp(%_directory%, K7.+?(?=[-)]) ,$1)
The resulting catalog id just looks like this:
,$1)
It looks like it just took the last parameter of the function and used it as a string directly, which makes me think that something is not escaped properly, but there doesn't seem to be any documentation on how to escape characters in actions. I tried multiple variations with no luck.
Any ideas on this, or even better, direct and clear documentation on what is actually expected here? Thanks.