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 constructionTechnical partThis part comes for a big part from the unofficial guide of picmixer Not yet translatedFinds 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 |