I have a set of files with YY-MM-DD dates in the file names, but they're really inconsistent:
A_39_09_21_morestuff.mp3
39_09_21ABC.mp3
I'd like to parse these values out and write them to the comment field. Been trying to puzzle out $regex(%title%,d{2}_d{2}_d{2}) but that doesn't seem to work for files like
stringstuff39_09_21morestuff.mp3
string_stuff_39_09_21+_more+stuff.mp3
39-09-21stuff.mp3
stuff39-09-21.mp3
I can eventually work out the right regex but I can't get the $regex function to work and am looking for an example.
Are there any examples of parsing a result from a regex and writing that parsed value into a field?
The filename isn't the title.
The regular expression you use does not use the correct syntax. It should be \d for digits.
Alos, I am missing the result part. $regexp('stringstuff39_09_21morestuff.mp3',.*(\d\d_\d\d_\d\d).*,$1)
should work.
Has a hyphen instead of an underscore, so the pattern does not match.
You could use $regexp('stringstuff39-09-21morestuff.mp3',.*(\d\d.\d\d.\d\d).*,$1)
Or $regexp(%_filename%,.*(\d\d.\d\d.\d\d).*,$1)
for all of these files.
I'm OK doing multiple tag-tag passes, but I can't get the "take 00-00-00" part to work. I get that xx-xx-xx won't match the regex and that's ok but the other two should be parsing and they're not.
I copied file name ot title and am trying to use tag-tag but spec below doesn't return anything.
field COMMENT
expression (%title%,.*(\d\d.\d\d.\d\d).*,$1)
My ultimate goal is to parse the filename before 00-00-00 into album, the 00-00-00 (or 00-xx-xx) into comment and everything after into title. Because the whole name is delimited with _, I can't just use filename->tag.
does not have 3 pairs of digits separated by any character but only 2 digits ("52") followed by another string which happens to have something like placeholders in the shape of "-xx-xx".
But those x-ses are no digits.
Right, that's kind of my next problem. At this point I'm wondering if it would be better just to go with a Python program to read the directories and fileglob, but i think MP3Tag is a really capable program and it -almost- seems possible.
I am always a friend of filters - so why don't you filter for
%_filename% HAS -xx-xx
and then treat the files with Format string: $regexp(%_filename%,.*(\d\d-xx-xx).*,$1)
And then you check for files that do not have a comment and the digits
%_filename% MATCHES "\d\d.\d\d.\d\d" AND %comment% MISSING
and treat it with the other regular expression?
I doubt that a python script would do any better if the found pattern is not really clear.
Deleted the previous post as it didn't have a leading 0 but this one does:
I want to parse the filename as
Part before 00-xx-xx : Album (Famous_Fathers)
Part including 00-xx-xx: Comment (41-xx-xx)
Part after 00-xx-xx: Title (24_Fathers_In_The_Household)
Can I do this in one pass, and if not how can I specify those parts? Tag-Tag at least parsed something but Filename-Tag doesn't parse anything, I think because it wants you to tell it %album%%title%%comment% but the duplicate _ delimiter here makes that impossible.
I read the documents but the $regex function at (Replace with Regular Expression – Mp3tag Documentation) didn't offer any examples, if there are examples somewhere of parsing a regex into multiple fields (or doing multiple regexes, etc) I will work on adapting those but right now I can't seem to get started with anything that works.
You can not match _xx_xx if your filename includes -xx-xx
A working regex for exactly this filename: Famous_Fathers_41-xx-xx_24_Fathers_In_The_Household
to get the ALBUM from the _FILENAME would be: $regexp(%_FILENAME%,(.*)_(\d\d-xx-xx)_(.*),$1,1)
To get the COMMENT replace $1 with $2
To get the TITLE replace $1 with $3
Try an action of the type "Guess value" with
Source: $replace($regexp(%_filename%,(.*)(\d\d-xx-xx)(.*),$1==$2==$3),_, )
Target string: %album%==%comment%==%title%