Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Can $if() or TF be used in "Automatically fill values"? (Read 5918 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Can $if() or TF be used in "Automatically fill values"?

here is example:

source: %tmp%
pattern: $if($strstr(%tmp%,Genre),%genre%)

I wanted to check if string 'Genre' exist in tag %tmp%, and if exist than write %tmp% value to %genre% tag

What am I doing wrong?
Thanks

Can $if() or TF be used in "Automatically fill values"?

Reply #1
The pattern field is what it says it is - No titleformatting, you just specify what the pattern of the source is.

The source accepts titleformatting. Set source to $if($strstr(%tmp%,Genre),%tmp%,%genre%) and pattern to %genre%.

Can $if() or TF be used in "Automatically fill values"?

Reply #2
OK, here is real example: I have custom tag AMG which might have genre, style, mood and theme words in it. They indicate if that tag exist (should be written) - it's like that last.fm script for MusicBrainz tagger if one knows about it:
%amg% = Genres: rock // Styles: Thrash // Moods: Epic // Themes: Victory
Now I use pattern: Genres: %genre% // Styles: %style% // Moods: %mood% // Themes: %theme%

which is OK, but if some "inner" tag doesn't exist than this pattern fails, (i.e. style is missing it indicator):
%amg% = Genres: rock // Moods: Epic // Themes: Victory
Now using the pattern doesn't results correctly

I'm quite sure there is way to do this but right now I don't know about it

Can $if() or TF be used in "Automatically fill values"?

Reply #3
Here is shortest solution that I run to:

source:
Code: [Select]
\\$if($strstr(%amg%,Genres: ),$substr(%amg%,9,$sub($strstr(%amg%,' \\ '),1)))\\$if($strstr(%amg%,Styles: ),$substr($substr(%amg%,$strstr(%amg%,Styles: ),$len(%amg%)),8,$sub($strstr($substr(%amg%,$strstr(%amg%,Styles: ),$len(%amg%)),' \\ '),1)))\\$if($strstr(%amg%,Moods: ),$substr($substr(%amg%,$strstr(%amg%,Moods: ),$len(%amg%)),8,$sub($strstr($substr(%amg%,$strstr(%amg%,Moods: ),$len(%amg%)),' \\ '),1)))\\$if($strstr(%amg%,Themes: ),$substr(%amg%,$add($strstr(%amg%,Themes: ),8),$len(%amg%)))

pattern:
Code: [Select]
\\%genre%\\%style%\\%mood%\\%theme%


[edit] Linked here 

Can $if() or TF be used in "Automatically fill values"?

Reply #4
You could use Masstagger with multiple "Guess value from other fields..." actions like "Genres: %genre% \\", "\\ Styles: %style% \\", "\\ Moods: %mood% \\", "\\ Themes: %theme%".

Or shorten a bit that thing of yours using variables:
Code: [Select]
$if($put(a,$strstr(%amg%,Genres: )),$substr(%amg%,$get(a),8),$sub($strstr(%amg%,' \\ '),1)))\\
$if($put(a,$strstr(%amg%,Styles: )),$substr($substr(%amg%,$get(a),$len(%amg%)),8,$sub($strstr($substr(%amg%,$get(a),$len(%amg%)),' \\ '),1)))\\
$if($put(a,$strstr(%amg%,Moods: )),$substr($substr(%amg%,$get(a),$len(%amg%)),8,$sub($strstr($substr(%amg%,$get(a),$len(%amg%)),' \\ '),1)))\\
$if($put(a,$strstr(%amg%,Themes: )),$substr(%amg%,$add($get(a),8),$len(%amg%)))
Full-quoting makes you scroll past the same junk over and over.

Can $if() or TF be used in "Automatically fill values"?

Reply #5
And I was thinking where is the saviour

Thanks for reply, it's shorten a bit, but again too long for "normal" usage, so I changed the script for which it was intended.
I used mentioned lastfm script for MusicBrainz tagger in the past and don't remember how I splited their values which were written similarly in %comment% tag. Or maybe I didn't - don't know, anyway it seems strange to me that foobar needs such a long pattern for the example

Can $if() or TF be used in "Automatically fill values"?

Reply #6
You could use Masstagger with multiple "Guess value from other fields..." actions like "Genres: %genre% \\", "\\ Styles: %style% \\", "\\ Moods: %mood% \\", "\\ Themes: %theme%".
I wanted to create masstagger script as it's good idea and save it for future use but it's not good solution:
 - "\\ Themes: %theme%" won't work, but there must be added some temp tag in front, i.e. "%temp% \\ Themes: %theme%"
 - "\\ Styles: %style% \\" won't work if Styles: is missing - %style% will be assigned with wrong value
 - masstagger actions aren't sequenced: when using properties you can use "Automatically fill values" then use other actions in properties dialog in one step without affecting previous action - masstagger can't do this, i.e. you can't assign value from some tag field and then in later action remove that field

[edit] corrected

Can $if() or TF be used in "Automatically fill values"?

Reply #7
OK, never mind then. I didn't really try it, just thought it could be a better automation than going through "Automatically Fill Values..." multiple times with different patterns manually in Properties, but with those limitations, it's really not possible.
Full-quoting makes you scroll past the same junk over and over.

 

Can $if() or TF be used in "Automatically fill values"?

Reply #8
Just made it work with Masstagger. You need 4 "Guess value from other fields" actions, each like this:
Source format: %amg% //
Guessing pattern: %%Style: %style% //%%

Next one:
Guessing pattern: %%Mood: %mood% //%%

etc.

Can $if() or TF be used in "Automatically fill values"?

Reply #9
Thanks  Done already: http://www.hydrogenaudio.org/forums/index....st&p=667009

I fill a bit silly now. I didn't had to literally follow Yirkha's suggestion + masstagger actions ARE sequenced

[edit] Those double percentages works great, although I don't understand them (something like dummy tags?)
thanks

[v] yeah, I'll update the script

done!

Can $if() or TF be used in "Automatically fill values"?

Reply #10
My version degrades properly if any information is missing and does not need to be executed in sequence.