Foobar 2000
  Home
  First steps
  Entry
  Pictures
  Settings
  Replaygain
  DSP
  Playlist
  About tags
  Tags
  CD writer
  Freedb
  Context menu
  Sidebar
  FAQ
  Masstagger
  Links
  Map

  0.9.X manual











The use of the masstagger is made at your own risks. I could not be considered responsible for any mishandling, mistake or error from me or you.




















Page in construction

Technical part

This part comes for a big part from the unofficial guide of picmixer

For some standard of the non common tags, go there.

Foobar uses TAGZ langage. For the description of the main functions, view the titleformat_help.html in your foobar folder. Masstagger is useful to introduce tags that you consider as important but are not common to everybody(especially for classical music listeners).

To write properly any script you must make it clean, with breaklines and Co. or you will be lost to know where your code is not correct and you won't be able to ask anyone to help you as it will be messy and not understandable (even by the software itself!!). You have to take some good customs before it is too late.

the basis:
the usual way to use a tag is by %tag% for example: %artist%, %title%, %tracknumber% but could be %_codec%,%_lenght% etc... But don't boggle the Tag name and its value. artist is the name of the tag. Limp Bizkit, Bob Dylan some values of the tag artist. As a consequence %Bob Dylan% or %Limp bizkit% is not correct.

For the examples, It will be:
the original soundtrack of the movie cruel intentions:

and the album Homework of the daft Punk:

  • $abbr(%tag%): Creates abbreviation of %tag% (uses the first character of each word).
    Example:
    • $abbr(%title%) will return EYEM for Every You Every Me
  • $abbr(%tag%,N):Creates abbreviation of %tag% if %tag% is longer than N characters; otherwise inserts full value of %tag%.
    Example:
    • $abbr(%title%,15) will return EYEM but Coffee & TV
  • $add(N1,N2,...): Adds multiple integral numbers (N1+N2+...). Accepts any amount of parameters.
    Example:
    • $add(%tracknumber%,1) will increase each tracknumber by one
  • $and(x,y...): Performs logical AND operation on parameters (in other words:Checks if all of the argument are here.). For use with $if()-type functions and other logical operators.
    Example:
    • $if($and(%tracknumber%,%title%,%various%),%tracknumber%-%title%-%artist%,%title%) will return 01-Every you Every Me-Placebo but Daftendirekt because the various field is not present for the album made by daftpunk
    • $if($and(%year%,%genre%),%year%,%genre%) will return soundtrack and club because if the value %genre% exists, the value %year% doesn't exist
  • $ansi(%tag%) Converts %tag% to system codepage and back. Any characters that aren't present in the system codepage will be removed / replaced. Useful for mass-renaming files to ensure compatibility with non-unicode-capable software.
  • $caps(%tag%) Converts first letter in every word of %tag% to uppercase, and all other letters to lowercase.
    Example:
    • $caps(%title%) will transform WDPK 83.7 FM into Wdpk 83.7 Fm or EVERY YOU EVERY ME into Every You Every Me
  • $caps2(%tag%) Similar to $caps, but leaves uppercase letters as they are. Example:
    • $caps2(%title%) will transform WDPK 83.7 FM into WDPK 83.7 FM but Praise You (radio edit) into Praise You (Radio Edit)
  • $char(NNN) Inserts Unicode character no. NNN. for a description of the unicode characters go to their website
  • $crlf(): Inserts end-of-line (carrier return / linefeed) code. Useful for multiline scripts.
  • $cut(%tag%,N): truncates the %tag% value to its N first characters.
    Examples:
    • $cut(%album%,4) will give you Home
    • $cut(%title%,11) will give you Every you E
  • $directory(%tag%), $directory(%tag%,N): Extracts directory name from file path %tag%, optionally goes up by N directory levels.
    Example:
    • $directory(%_path%) (which is the same as $directory(%_path%,1)) will return sexe intentions (BO)
    • $directory(%_path%,2) will return MP3 Boris (Boris isn't my name, just one of my friends'..)
  • $div(N1,N2): Divides integral number N1 by integral number N2.
    Example:
    • $div(%tracknumber%,100) will divide by 100 the tracknumber value and truncates it into an integer value (0 if original number is 01, 1 if original number is 150)
  • $ext(%tag%) Extracts extension from file path / file name.
    Example:
    • $ext(%_path%) will return mp3
  • $filename(x) Extracts file name from full path.
    Example:
    • $filename(%_path%) will return 01. Every You Every Me
  • $fix_eol(%tag%) Scans %tag% for end-of-line marker (CR/LF), if found - truncates and appends " (...)".
  • $fix_eol(%tag%,action1) Scans %tag% for end-of-line marker (CR/LF), if found - truncates and appends action1.
  • $greater(N1,N2) Compares two integral numbers, tests if N1>N2. For use with $if()-type functions and other logical operators.
    Example:
    • $if($greater(%TRACKNUMBER%,100),$div(%TRACKNUMBER%,100),%DISC%) will divide by 100 the tracknumber if gretaer than 100, else will return %DISC%
  • $hex(N) Converts integral number N from decimal to hexdecimal notation.
    Example:
    • $hex(%_playlist_number%) to have your playlist number in hexdecimal
  • $hex(N1,N2) Converts integral number N1 from decimal to hexdecimal notation, pads with zeros to N2 digits.
    Example:
    • $hex(%_playlist_number%,3) to have your playlist number in hexdecimal and with a length of three
  • $if(%tag%,action1,action2): if the %tag% is existing is completed returns the action1, else does the action2
    Example:
    • $if(%tracknumber%,%tracknumber% - %title%, %title%) if the tracknumber field exists, will return 01 - Every You Every Me else, will return Every You Every Me
    • $if(%various%,%tracknumber% - %title% - %artist%,%tracknumber% - %title%) will return 01 - Every You EverY Me - Placebo, but 01 - Daftendirekt
  • $if2(%tag%,%tag%) Same as $if(%tag%,%tag%,b).
    Example:
    • $if2(%tracknumber%,%title%) if the tracknumber field exists, will return 01 else, will return Every You Every Me
    • $if2(%various%,%tracknumber% - %title%) will return 1 (the value is set to 1 for various that's why it returns 1), but 01 - Daftendirekt
  • $if3(%tag&%,%tagé%,%tag3%,..) Returns first of items being true/non-empty.
    Example:
    • $if3(%year%,%%genre%) will return
    • $if3(%artist%,%year%) will return Placebo, Daft Punk
    • $if3(%genre%,%artist%) will return soundtrack, club
  • $num(%tag%,N): will return the numerical value and complete it to N characters with zero
    Example:
    • $num(%tracknumber%,2) will give you 03 for the value 3 and 13 for 13.
  • $left(%tag%,N) will return the N first characters by the left of the tag value
    Examples:
    • $left(%album%,4) will give you Home
    • $left(%title%,15) will give you Every you Every
    • $num($left(%_filename%,2),2) will give you 03 if the file is named 03 - Daft Punk - Daftendirekt.mp3
  • $right(%tag%,N) will return the N first characters by the right of the tag value
    Examples:
    • $right(%album%,4) will give you work
    • $right(%title%,12) will give you you Every Me
    • $num($right(%_filename%,2),2) will give you kt if the file is named 03 - Daft Punk - Daftendirekt.mp3
  • $strchr(%tag%,Y): Finds first occurrence of character Y in string %tag%.
    Example:
    • $cut(%title%,$strchr(%title%,y)) will return Every
  • $strrchr(%tag%,Y): Finds last occurrence of character Y in string %tag%.
    Example:
    • $cut(%title%,$strrchr(%title%,y)) will return Every You Every
  • $sub(X,Y) Subtracts integral number Y from integral number X
    Example:
    • $sub(%tracknumber%,1) will decrease by one each tracknumber
  • $ifgreater(N1,N2,action1,action2) If number N1 is greater than number N2, return/execute action1, otherwise return/execute action1.
    Example:
    • $ifgreater(%tracknumber%,1,%title%,$upper(%title%)) will return EVERY ME EVERY YOU but Praise you (radio edit)
    • $ifgreater(%tracknumber%,100,$sub(%tracknumber%,100),%tracknumber%) will return 60 for a tracknumber which is 160
  • %tag%: returns the value of the corresponding tag. you can put several tags in the same chain (see example 3)
    Examples:
    • %artist% will give you Daft Punk
    • %album% will give you Soundtrack cruel intentions
    • %album% - %genre% will give you Homework - Club
Example:

Not yet translated

Finds first occurence of character X in %tag% and returns everything in front of X: $puts(spacer,$strchr(%tag%,X)) $trim($left(%tag%,$sub($get(spacer),1))) Example: blah X bleh or blah X bleh X bluh returns blah (ie.: artist_album_title ----- title, in case X is _ ) NOTE:In the next few strings I have decided to make it possible to define the %tag% that should be edited and the character or string that is used to determine where to trunctuate as variables in the beginning of the string as $puts(tag,%tag%), $puts(char,X), etc. Basically the reason I have done this is to make it simpler to edit these strings, to what you exactly want them to do at the very moment, in the rather narrow masstager input field. That way it is possible to enter the needed tags and characters only once in the beginning of the line. Again simply replace %tag% and X by the desired values. Also all of these strings will trim off the trailing and leading spaces of the output (in case there are any). Finds first occurence of character X in %tag% and returns everything in front of X: $puts(char,X)$puts(tag,%tag%)$puts(spacer,$strchr($get(tag),$get(char))) $trim($left($get(tag),$sub($get(spacer),1))) Example: blah X bleh or blah X bleh X bluh returns blah (ie.: artist_album_title -----> title, in case X is _ ) (Note this does exactly the same as the last string mentioned above, except for the introdution of the two variables in the front, meant for easy editing) Finds last occurence of character X in %tag% and returns everything in front of X: $puts(char,X)$puts(tag,%tag%)$puts(spacer,$strrchr($get(tag),$get(char))) $trim($left($get(tag),$sub($get(spacer),1))) Example: blah X bleh returns blah and blah X bleh X bluh returns blah X bleh Finds first occurence of character X in %tag% field and returns everything after X: $puts(char,X)$puts(tag,%tag%)$puts(spacer,$strchr($get(tag),$get(char))) $trim($right($get(tag), $sub($len($get(tag)),$get(spacer)))) Example: blah X bleh returns bleh and blah X bleh X bluh returns bleh X bluh Finds last occurence of character X in %tag% field and returns everything after X: $puts(char,X)$puts(tag,%tag%)$puts(spacer,$strrchr($get(tag),$get(char))) $trim($right($get(tag), $sub($len($get(tag)),$get(spacer)))) Example: blah X bleh returns bleh and blah X bleh X bluh returns bluh Finds first occurence of character X and last occurence of character Y and returns everything in between: $puts(char1,X)$puts(char2,Y)$puts(tag,%tag%) $puts(spacer1,$strchr($get(tag),$get(char1))) $puts(spacer2,$strrchr($get(tag),$get(char2))) $trim($substr($get(tag),$add($get(spacer1),1),$sub($get(spacer2),1))) Example: blah X bleh Y bluh returns bleh Note that in most cases X will probably be equal to y here. Finds first occurence of string XYZ and returns everything in front of string XYZ: $puts(string,XYZ)$puts(tag,%tag%)$puts(spacer,$strstr($get(tag), $get(string))) $trim($left($get(tag),$sub($get(spacer),1))) Example: blah XYZ bleh returns blah Note that string XYZ can basically be any combination of characters or words. Finds first occurence of string XYZ in %tag% field and returns everything after XYZ: $puts(string,XYZ)$puts(tag,%tag%) $puts(spacer,$strstr($get(tag),$get(string))) $trim($right($get(tag),$sub($len($get(tag)), $add($get(spacer),$len($get(string)))))) Example: blah XYZ bleh returns bleh Extracting Information from Relative File Paths: As suggested I have included a small section on how to extract different values from their relative file paths. To do so I will use the following example path to extract information from ...\Genre\Artist\Album[Date]\01_Title.mpc sets title: %_filename% returns title as 01_Title.mpc and $puts(char,_)$puts(tag,%_filename%) $puts(spacer,$strchr($get(tag),$get(char))) $trim($right($get(tag),$sub($len($get(tag)),$get(spacer)))) returns title as Title.mpc sets album: $directory(%_path%,1) returns title as Album[Date] $puts(char,'[')$puts(tag,$directory(%_path%,1)) $puts(spacer,$strchr($get(tag),$get(char))) $trim($left($get(tag),$sub($get(spacer),1))) returns album as Album NOTE that the [ is quotes as '[' , the reason for this is for it to be recognized as a character and not as a command syntax, you will probably have to ommit the quotation marks for most other characters. sets artist: $directory(%_path%,2) returns artist as Artist sets genre: $directory(%_path%,3) returns genre as Genre sets tracknumber: $num($left(%_filename%,2),2) returns tracknumber as 01 Obviously a lot more is possible, but then this was just supposed to be a short introduction. I would say simply copy a few of your files, and play around with it. The Rename Files Dialog The rename files dialog enables you to automatically rename your files according to your metadata tags in an automated way. You will first need to select all the tracks you want to rename and then right click and select: Masstagger/rename files. Select in the masstagger dialog wich output directory you mant to use and wether to generate subdirectories according to the / \ characters. I will give a few examples for renaming strings below. Examples To rename your files to "tracknumber_title.ext (i.e. 08_The Glass Bead Game.mpc)" you will need to enter the following syntax in the Output file name format field CODE %tracknumber%_%title%No need to create subdirectories in this case. To rename your files to "/artist - album/title.ext (i.e. Thievery Corporation - Sounds of the Thievery Hi-Fi/08_The Glass Bead Game.mpc) and create the appropriate subdirectories you will need the following syntax CODE /%artist% - %album%/%tracknumber%_%title%In this case make sure the "create subdirectories" checkbox is ticked. To rename your files to "/artist/album/tracknumber_title.ext (i.e.: /Thievery Corporation/Sounds of the Thievery Hi-Fi/08_The Glass Bead Game.mpc) use the following syntax CODE /%artst%/%album%/%tracknumber%_%title% In case you generally make use of "album artist" tags (or anything similar) for various albums files you can replace %artist% with CODE $if2(%album artist%,%artist%)in any of the above strings. Note One reason why it is convenient to use the masstaggers rename files function is that this way Foobar2000's database will automatically get updated to the current changes. Of course this only gives a general idea of what is possible and all kind of different filenaming schemes can be used for this. And as usual, please don't hold me responsible in case this makes a mess out of any of your files In case the renamer ever does anything unexpected, don't dispair, it is usually very easy to fix with just another renaming operation. Well, if your still with me now I guess thats quite a good sign and at least you didn't get all to bored along the way. Hope this is all somewhat comprehensible and can give people who are new to this a general idea on how things work. Concerning Foobars Masstagger at least. Any suggestions and especially critisism, corrections and add ons extremely welcome. Oh yeah and in case you ever get bored of any of those old bad quality Kazaa files that might still be lying around on your harddisk you can always replace %tag% by $rot13(%tag%) , mess them all up a bit and make your filenames gow all blowfish. (allright, for all humorless people, it's a joke, PLEASE DON'T DO THIS, except of course if you are really bored with them) Hmh lots of blehs and blahs, guess I should have used something a bit more creative . Otherwise I might as well have called this thread BlahBlah. In case you find any ingenious strings or even better simple ones, I suggest everyone can simply post them in this thread. EDIT: Damn this page turned out really wide, Anything I can do about that. (Well, except posting annoyingly long posts like this one ) EDIT2: Allright, this works better now. Thanks Jan EDIT3: Included relative file paths section EDIT4: Removed strange formatting again. Thanks to SamK for taking most of the workload off me The 0.8 syntax is a c-like one. So instructions have to be sepperated by semicolons, function arguments are comma-sepperated enclosed in parentheses and instruction blocks (for if-statetements) are enclosed in curly braces. To activate the new 0.8 syntax, the first line of the script has to be "#script 1" (without quotes). [edit] Text Handling Strings have always to be enclosed in double-quotes. Strings are concated by "#" (eg. "pre"#"post" equals "prepost"). Following special characters can be created with escaping (there are various others, but they are useless in formatting-strings): \n newline \t tabulator \\ backslash \" double-quotes [edit] Variable Handling Variables are typeless and don't need to be declared. Type-conversions are done automatically. var = "2string"; var += 4; print(var); Prints "6"; [edit] Operators Following Operators are available (with their common meaning): -- ++ ! ~ % / # >> << >= <= > < != == & ^ && || : #= |= ^= &= >>= <<= -= += %= /= *= = [edit] Control Structures [edit] if There are two possible syntaxes for the if construct: if(condition) single_instruction(); if(condition){ multiple(); instructions(); } The following instruction/everything within the curly brackets is only executed, if condition is neither 0 nor an empty string. [edit] else Has to follow an if construct and is only executed, if the if construct wasn't. Example: if(var == 1){ print("var is one"); } else { print("var is not one"); } [edit] switch A switch statement allows a single variable to be compared with several possible integers. If the variable matches one of the integer, then a execution jump is made to that point. To jump to the end of the switch construct, use "break;" A integer can not appear more than once, and there can only be one default expression. switch (variable){ case int: statements...; default: statements...; } Example: switch(betty){ case 1: print("betty=1"); case 2: print("betty=2"); break; case 3: print("betty=3"); break; default: print("Not sure."); } If the variable betty is 1, then two lines are printed: betty=1 and betty=2. If betty is 2, then only one line is printed: betty=2. If betty=3, then only one line is printed: betty=3. If betty does not equal 1, 2, or 3, then "Not sure." is printed. [edit] Functions [edit] Output print(arg) Outputs arg set_color(r,g,b) set text color for following output; will invert the color on selected fields set_color(r,g,b,sr,sg,sb) set text color for following output to r,g,b on non-selected fields and to sr,sg,sb on selected fields set_color() reset to default color [edit] Metadata meta(meta_field) Returns the value of the metadata field meta_field meta_test(meta_field) Returns 1 if metadata field meta_field is set, otherwise 0 channels() returns either "mono" or "stereo" codec() same as info("codec") info(tech_info_field) Returns the value of the techinfo field tech_info_field extra(internal_info) Returns one of the following internal infos. [edit] Internal info fields path holds full file name with path path_raw holds full file name including path and protocol filename holds file name without extension filename_ext holds file name with extension directoryname holds the directory name subsong holds subsong index foobar2000_version holds foobar2000's version string filesize holds filesisze in bytes length holds length of track in formatted form length_ex holds length of track in formatted form, but with floatingpoint second-value length_samples holds length in samples length_seconds holds length in seconds length_seconds_fp holds length in seconds, with floatingpoint accurracy [edit] Special fields (only aviable in playlist) isplaying holds '1' if file is currently playing and empty string otherwise. ispaused holds '1' if playback is paused, empty string otherwise. playlist_number holds playlist index of specified item. playlist_total holds number of files in playlist. playlist_name holds name of playlist containing specified item. [edit] Special fields (only aviable in status bar, window title and copy command) time_elapsed holds elapsed time time_remaining holds remaining time until track ends time_total holds total length of track time_elapsed_seconds holds elapsed time in seconds time_remaining_seconds holds remaining time in seconds time_total_seconds holds total track length in seconds ispaused holds '1' if playback is paused and empty string otherwise time_total / time_total_seconds get data from playback core while length% / length_seconds get data from database, in some rare cases either of them may be more reliable. You can see all metadata and tech info fields in file info box. [edit] String Functions ansi(string) converts string to system codepage and back. Any characters that aren't present in the system codepage will be removed / replaced. Useful for mass-renaming files to ensure compatibility with non-unicode-capable software. char(x) inserts Unicode character no x stricmp(str1,str2) compares str1 with str2 case-insensitive, returns 1 if they are equal, 0 otherwise strcmp(str1,str2) compares str1 with str2 case-sensitive, returns 1 if they are equal, 0 otherwise is_empty(string) returns 0 if string is "", otherwise 1 (sounds weird, but it is that way) strlen(string) returns the length of the given string lower(string) converts string to lowercase upper(string) converts string to uppercase right(string,int) returns int first right characters from string left(string,int) returns int first left characters from string repeat(string,int) repeats string int times cut_right(string,int) alias for left() cut_left alias for right() padcut_right(string,int) pads string to int characters or truncates to int if longer pad_right(input,pad_length[,pad_str]) seems to do nothing in v0.8.3 padcut_left(input,pad_length[,pad_str]) behaves like pad_left, but returns only the pad_length first right characters from input, if it is shorter than pad_length pad_left(input,pad_length[,pad_str]) returns the input string padded with pad_str on the left to the specified padding length. If pad_str is not supplied, the input is padded with spaces