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: $if() enhancement (Read 3102 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

$if() enhancement

I need some way to determine if a file contains a tag. As I understand, the method people use right now is to check if %title% or %album% or some other field exists, and if not, display %filename%.

But some of my files don't have an %album% field, and some don't have a %title% field (either could be unknown). They may have other fields that I wish to display. So as it is now, if the field I check for isn't there, it falls back to %filename%.

So I'd like something like: $if(tag=true,%foo%,%filename%).

This may not be the best explanation, but I hope you get the idea. If not, flame away.

Edit: Some clarification.

This is my string.

Quote
000080$num(%_playlist_number%,4). $if(%title%,$padcut($if(%artist%,%artist%,),30) '['$if(%date%,FF0000%date%,    )']' $padcut($if(%album%,%album%,),30) '['FF0000'#'$if(%tracknumber%,$num(%tracknumber%,2),  )']' $padcut($if(%title%,%title%,),30),808080%filename%) $if(%__replaygain_album_gain%,'['FF0000%__replaygain_track_gain%' / '%__replaygain_album_gain%']',)


And it yields the following result:

Foobar 2000 screenshot.

The whole title formatting string is wrapped in an $if() statement. And if it's false, it just displays the filename.

$if() enhancement

Reply #1
$if(tag=true,%foo%,%_filename%) is exactly how it works right now, if I'm not mistaken.

$if(%foo%,if foo exists display this,else display this) is $if()'s syntax.

and with $padcut() you don't have really need the "$if(%title%,insert main string,%_filename%) sub string" structure, as you can just do "$padcut(%artist%,20) $padcut(%date%,4) $padcut(%album%,30) $padcut(%tracknumber%,2) $if2(%title%,%_filename%) substring"

some other hints: instead of using $if(%foo%,Foo is %foo%,) you can use [Foo is %foo%]
instead of using $if(%foo%,%foo%,fallback text) you can use $if2(%foo%,fallback text)
'[''#' can be shortened into '[#'

Quote
$num(%_playlist_number%,4). $padcut(%artist%,30) '['$if2(%date%,    )']' $padcut(%album%,30) '[#'$if2($num(%tracknumber%,2),  )']' $if2($padcut(%title%,30),%_filename%) $if(%__replaygain_album_gain%,'['%__replaygain_track_gain%' / '%__replaygain_album_gain%']',)


You can change those $if2()s into $padcut()s. That, and integrating color codes, is left as an exercise for the reader : )

edit: oops. The above string isn't identical is it? I guess then you'll have to wrap the main string with $if() after all.

$if() enhancement

Reply #2
And you should substitute [%tag%] for $if(%tag,%tag,)

$if() enhancement

Reply #3
Hi folks,

On a related note, how does one test to see if an album is a various artists album, or if it is a single artist album?

If its a Various artists album, it should display as:

ALBUM - TRACK# - ARTIST - TITLE

If it is a single artist album, it would be:

ARTIST - ALBUM - TRACK# - TITLE


I would appreciate any and all suggestions.

Thanks.

$if() enhancement

Reply #4
use the $ifgreater and $strstr() commands.

Code: [Select]
$ifgreater($strstr(string,value), value, true, false)


$strstr params:
string - the string to check if value is contained within it
value - the value to check if contained in the string

$ifgreater params
$strstr() - anything can be used here that will produce a number
value - the value the number must be greater than
true - print this if the number is greater than the value
false - print this if the number is less than the value

for example if you have your VA albums stored in c:\music\albums\various\blah, you could do

Code: [Select]
$ifgreater($strstr(%_path%,various), 0, ALBUM - TRACK# - ARTIST - TITLE, ARTIST - ALBUM - TRACK# - TITLE)


the $strstr() will return a value greater than 0 if the string in the second param ("various" in this case) is contained in the first param ("%_path" in this case) and isn't at the start of the first param (eg "various\blah"=0 instead of "c:\various\blah"=3). Make sure there isn't a space between the comma and the string to check for.

Hope this helps

$if() enhancement

Reply #5
Quote
use the $ifgreater and $strstr() commands.

Code: [Select]
$ifgreater($strstr(string,value), value, true, false)


$strstr params:
string - the string to check if value is contained within it
value - the value to check if contained in the string

$ifgreater params
$strstr() - anything can be used here that will produce a number
value - the value the number must be greater than
true - print this if the number is greater than the value
false - print this if the number is less than the value

for example if you have your VA albums stored in c:\music\albums\various\blah, you could do

Code: [Select]
$ifgreater($strstr(%_path%,various), 0, ALBUM - TRACK# - ARTIST - TITLE, ARTIST - ALBUM - TRACK# - TITLE)


the $strstr() will return a value greater than 0 if the string in the second param ("various" in this case) is contained in the first param ("%_path" in this case) and isn't at the start of the first param (eg "various\blah"=0 instead of "c:\various\blah"=3). Make sure there isn't a space between the comma and the string to check for.

Hope this helps

Krispy,

Thanks. I appreciate your reply. To use your method would mean that I would have to place all my VA albums in a folder with a name to test for, whether it is "Various" as in your ex. or anthing else.

My files are organised like this:

Single artist albums:
Code: [Select]
     
D:/MUSIC/ARTIST/ALBUM/artist - album - track# - title.mp3

VA albums
Code: [Select]
D:/MUSIC/ALBUM/album - track# - artist - title.mp3

If it is series of VA albums such as the Cafe Del Mar series (Vol. 1 to 9), then:
Code: [Select]
D:/MUSIC/CAFE DEL MAR/VOLUME #/album - track# -artist - title.mp3

Obviously, the test for a particular string in the path name would not work in this case, unless of course, I were to place all the VA albums into a separate folder.

It seems, to me anyway, that the only way to do it while keeping my files organised as they are, would be to use a tag field to store a value to test for. 

Again, thanks for your reply. You've given me some options to think about.

$if() enhancement

Reply #6
Wiske88,

i think you best option is probably to use a tag field to determine the differences, unless you want to use lots of $if statements (which would get rather ugly very quickly).