Checking if TITLE has something before changing TRACK

I have this action that copies the first word from FILENAME to TRACK, if it is a 2 or 3 digit number

Format value "TRACK": $mod(%_FILENAME%,100)

That is for the purpose of auto-numbering of new files, based on the name of the file. But this action is used be me also after renaming a file, to update the TITLE [by coping the FILENAME to it]. And so [long story short] if the song has a title like
"99 Problems"then I have a real problem. But I could avoid that issue if this action of mine would first check, if the TITLE tag field is already filled with anything. So, can anyone rewrite it please, so that it would check first if there is something in the TITLE tag, and copy the 2-3 digits to TRACK only if the TITLE happens to be empty?

Dont know why you're using mod. num function here with setting 1 does the same.

Use this. I think this is what you want.

Format: TRACK
F String: $iflonger(%title%,0,%track%,$num(%_filename%,1))

This works, thank you. But only half way. Because, as it seems I forgot to point some things out

EXAMPLE 1
In a case of for example

FILENAME: 99 Problems
TITLE: 99 Problems
TRACK: 10this action should give
FILENAME: 99 Problems
TITLE: 99 Problems
TRACK: 10

EXAMPLE 2
But in case of

FILENAME: 99 Problems (Remix)
TITLE: 99 Problems
TRACK: #the point of executing such action would be to end up with
FILENAME: 99 Problems (Remix)
TITLE: 99 Problems (Remix)
TRACK: #[my TRACK fields sometimes have something else than numbers]

EXAMPLE 3
And in case of

FILENAME: 99 Problems
TITLE: [empty]
TRACK: [empty]it would unfortunately produce
FILENAME: 99 Problems
TITLE: Problems
TRACK: 99which would then have to be corrected manually to
FILENAME: 99 Problems
TITLE: 99 Problems
TRACK: [empty]which I accepted, because I hundreds times often use beginning of names of files for numbering TRACKs than naming TITLEs from FILENAMEs

All of those examples show the TITLE and not the TRACK getting changed. Can you edit that post and add the other tyes you want so I'm sure of what to do?

Seems like you need the TRACK and TITLE changed depending on variables which I'm not 100% sure on.

Those examples were in regards to both auto-numbering and updating TITLE at the same time, based on FILENAME

In example 1, nothing is changed. Because TRACK already has a number and both FILENAME and TITLE are to be the same

In example 2, TITLE is changed. Because the correct / new one was in the FILENAME. But the TRACK is not changed because it is already filled with something

In example 3, FILENAME is divided between TRACK and TITLE, because both those fields were empty. And normally it would be the needed behavior, but in this particular example I will have to correct in manually

But after rethinking the whole ordeal, this is how the action should behave:

A] if there are 2 digits in front of a file - copy them both to TRACK

B] if there are 3 digits in front of a file - copy the 2nd and 3rd digit to TRACK

C] if such 2 or 3 digits are followed by "-" / " -" / " - " / "- " or by "." / " ." / " . " / ". " - do the same as in A / B

D] if TITLE has any kind of value - do not execute A / B

E] if there is 1 digit in front of a file - do nothing

F] if there are 4 or more digits in front of a file - do nothing

I think the whay to do this is to first format the FILENAME the way you want it. Keep it standard.

    • TITLE 01, 02. - TITLE 02, etc

Then worry about what happens the other tags.

I'm sorry but I'm super confused what you want to achieve.

Was that not an example in the first type where you had 99 problems as a FILENAME thus making this action useless.

Again if you concentrate on the FILENAME first you can then move over to the tags to sort them.

BTW. Most people on this forum fill in the TAGS first and then worry about the FILENAME.

IMO. It's counter productive to worry about both at the same time.

In by book FILENAME is for the exact same data as TITLE [minus the problem of the possible length and illegal characters, for which I have substitutes applied automatically with actions]. And as I often go to a folder with a file explorer, it would be very bad for me to see a bunch of songs starting with "01", instead of seeing all of the files arranged in alphabetical order. I do not keep whole albums; and I have a folder for each artist in which I store all of the songs in which that folder artist is the leading / main / performer or band

This action in question will work properly with a file named "99 Problems"; but if the song happens to be really named "99 Problems" it will mess up the tags. And so this action will not be used be my on such file / song or used with a careful oversight [leading to manual correction afterwards]

And to be precise and to touch the core of the issue: If my "99 Problems" song already has a TRACK filled [with "5", "13", "20", "X", "#", "?", "." whatever] this action should check that out. So that if it sees a filled TRACK it does not change the value in it. But if it sees an empty TRACK fields, then it fills it- in this case with "99". In this case it is not really a track number but a part of the original title and as such will be removed by me manually from the TRACK tag field. This will happen very rarely but cannot be ignored

And the

rule is to act as a fail safe in cases exactly like "99 Problems". Because it is possible for my old file to not have a filled TRACK number, but it will have for sure a filled TITLE field. So checking only the TRACK field will be not enough. But checking if also the TRACK is filed is the way to go when dealing with a new file, that has all of the fields empty [as I always convert my files to FLACs / MP3s from edited WAVs and wipe out every tag from such new FLAC / MP3 before I start to tag them according to my rules, as some of the old / original tags get carried over through the editing and converting process]

First purpose of my whole big group of actions containing this discussed action is to fill empty tag fields in a completely new file; that is if only the FILENAME bears the certain / proper info. Those tag fields to be filled are TITLE, TRACK and DISCNUMBER; but recently I combined the number of disc with the number of track into one field [TRACK]. In the end, this saves me a lot of of time and frees me form a boring and repetitive work, which can easily produce errors that cannot by avoided even with actions [human error]. The second purpose is to update the TITLE, because if I change the name of the song it is most likely via the FILENAME field [and if sometimes I change name of the song via the TITLE tag field, I have no problem with updating the FILENAME based on data from TITLE with my well defined "TAG - Filename" icon]

This is why I want it precisely to work with a 2-3 digit number because for example I have dozens of songs starting with a 4 digits which stand for the year which is the part of the original title. And I do not want to have two separate actions groups for the first and second purpose because:
1] the rules for them are identical
2] the only problem is with a song like "99 Problems" or recording named "300 Years Later"
3] I do not want do have yet another line added to my list of actions, as my menu already in vertically way to big
4] currently there is no easy way of coping / moving actions between groups; and even if it would be possible, in time it will lead to mistakes [because after changing some rule / code in one group I could erroneously change it the other in a slightly different manner or even completely forget to do it, which in turn will make such two group actions identical only in theory]

Is it clear now why my modus operandi makes sense, with what do I need help with and [most important] what are the rules for that action?

I think I can make the whole shebang somewhat easier: I will switch from 2-3 system to only 3 digit

Tracks from double / triple /quadruple albums already are numbered like 201, 302, 403 etc.; so I could just rename tracks 01 / 02 / from single albums to 101 / 102 / 103 with a quick usage of FreeCommander [CTRL + M], prior to loading them to Mp3tag

I'll get back to this topic later on

And that was the right approach

I decided to treat only three digit numbers at the beginning of FILENAME. And so I went to my already existing and working action group and going [backwards] step by step [i.e. from the end to the first action] removed everything evoking two digits and also maid sure one digit and four digits were excluded as well. But that covers only my cleaning purposes [maintaining order with existing files]

So now I would like to know to how to copy from the beginning of FILENAME to TRACK a three digit number that can have form like these:

000
000.
000-
000 -

But in the very first case, such number has to followed by anything [because there can be song titled like "911"]

And overall [for all cases] it should ignore number consisting of 1, 2 and 4 or more than four digits [by simply not coping]

QUOTE (Zerow @ Aug 1 2017, 22:52) <{POST_SNAPBACK}>
like these:
000
000.
000-
000 -

But in the very first case, such number has to followed by anything [because there can be song titled like "911"]


I don't know why you don't just standardise these first.
000
000.
000-
000 -

to one. What's the point in having 4 different methods here for naming conventions?

If it were me, 000_filename goes here.ext would be perfect.

Anyway, If you've the right format in the filename like you say having the above filename "000. 911.mp3" and not just "991.mp3"

Then this will work.
Format

Field: TRACK
FString: $if($eql($regexp(%_filename%,'^(\d{3})[^\d].+','yes'),'yes'),$left(%_filename%,3),%track%)
QUOTE (stevehero @ Aug 2 2017, 01:01) <{POST_SNAPBACK}>
I don't know why you don't just standardise these first.
000
000.
000-
000 -

to one. What's the point in having 4 different methods here for naming conventions?

If it were me, 000_filename goes here.ext would be perfect.

I can only make rules for filenames / tag field only after they are incorporated

So those variations represent version that I have to work with in the beginning [when adding new files]. And Mp3tag is suppose to help me unify them [later on I get rid of track / disc numbers from FILENAME, relaying from further on on what I have in the TRACK field]

[And on the side note, your proposed system would not take into account files that do not have disc and / or track number]

QUOTE (stevehero @ Aug 2 2017, 01:01) <{POST_SNAPBACK}>
Anyway, If you've the right format in the filename like you say having the above filename "000. 911.mp3" and not just "991.mp3"

Then this will work.
Format

Field: TRACK
FString: $if($eql($regexp(%_filename%,'^(\d{3})[^\d].+','yes'),'yes'),$left(%_filename%,3),%track%)<!--QuoteEnd--></div><!--QuoteEEnd-->Yes this works as intended, thank you

And so, switching to the 000 format [getting rid of the 00 variation] and this one line of your code replaced my previous 8 actions

Perfect. :slight_smile:

FYI when you tag something and it doesn't exist you can wrap it in [...] Works for multiple tags.

So try this.

Add a title field can be anything to a test file
Leave the artist field empty.

Then try Format: ALBUM
[%artist% - ]%title%

Normally the result would be " - whatevertitleyouused" but by enclosing the ARTIST and - with [...] it doesn't return anything.

Format: ALBUM will work too, this time incorporating TITLE in the check.
[%artist% - %title%]