Rename files if track number is there or not

Hello
I have bulk removed leading and trailing spaces and moved 'The' to the correct position in the artist field

However the filename doesn't reflect the artist changes re 'The' change of position

I need 2 actions

1-if a track number exists, create a filename
$track$ - $artist$ - $title$

But if a track number doesn't exist
create a filename
$artist$ - $title$

Is this possible with 2 actions, can do separately

Thank you in advance

Of course not. The filename is something for the file system to manage the files. The only requirement for a filename is to be unique and obey the syntax rules.
Try 1 action of the type "Format value" for _FILENAME:
Format string: [%track% - ]%artist% - %title%

See also the documentation:

hello
there are two cases, one where a track number doesn't exist and one where a track number exists

can this be made as two actions please

thank you

It is not necessary to use 2 actions.
Please consult the documenation about format strings and the special purpose of square brackets.
Your reply also indicates that you have not tried my suggestion.

I can rename the filename easily using ALT1 but I want this to auto complete as I have 170K files to process

I have looked at the documentation and have come up with

Format Value
Field: _FILENAME
Format String:
$if(%TRACK%,$TRACK$ - $ARTIST$ - $TITLE$,$ARTIST$ - $TITLE$}

such that if a track number exists it will do one thing else if no track number exists it will do a different thing

Does this make sense :crossed_fingers:

Wasn't sure if I need String$ or just $

Re
Try 1 action:
Format string: [%track% - ]%artist% - %title%
Does this check for existence of TRACK then perform the remainder, if so that's very easy, if I am correct then need adapt it for instances when TRACK doesn't exist

Thanks

You still have not tried my suggestion.
Could you show me the documentation part that tells you variable names to look like

Have you tried it?

If you have two groups of files - those with track numbers and those without, and you want to reflect that in the filename, then you could create two actions. One would include the track number and the other would not.

Then, you could either sort by track number, or filter for those with/without. Perform the appropriate action on each group of files and you're good. Would definitely recommend running a few tests before blindly renaming 170k files though.

As was already suggested above, this one string handles both conditions.

[%track% - ] This part enclosed in square brackets is only included if the contents of the field (%track% in this example) exists. Otherwise the entire section within those brackets is excluded from the formatting.

Edit: corrected the field reference

TIL but why artist? Shouldn't it be track?

Yes. Typos happen.
@MotleyG 's explanation of the underlying mechanism was 100% correct.

Fixed the original reply to show %track% as the field in the current situation.

The general use case remains intact, where anything within a pair of square brackets will only be filled if the field referenced exists. Additional text such as the trailing " - " within the same brackets will also be ignored if the field does not exist.

If the OP @reddwarf4ever would finally try the suggestion from @ohrenkino's first answer, he would recognize the meaning of all the explanations and the documentation about Characters with Special Functionality:

[...] The contents of brackets are displayed only if at least one of the placeholders used inside the brackets has been found. An example use case is creating disc subfolders: [CD$num(%discnumber%,1)\] results in CD1\ if DISCNUMBER is 1 or an empty string if it’s not filled.

Ok
All very interesting
But still not sure if this does shat I need

Format string: [%track% - ]%artist% - %title%

I need track artist title if track exists

And just artist & title if track doesn't exist, so am I missing something :thinking:

Also there are 3 fields for an action, need to know which goes where, I'm still learning and finding it very difficult.

Thanks

Are you willing to try the suggestion or not?

:blush:


[%track% - ]%artist% - %title%

works perfectly

thank you ohrenkino

I just don't listen do I.......lol

I did try it :+1: