Help - Search - Members - Calendar
Full Version: can you use $if functions in mass-rename?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > General - (fb2k)
NogginJ
hey everyone,
why wont this code work when i use it to rename my files?

CODE
$if(%album artist%,$caps2(%album artist%)\'('%date%')' $caps2(%album%)\$num(%tracknumber%,2) - $caps2(%artist% - %title%), $caps2(%artist%)\'('%date%')' $caps2(%album%)\$caps2(%artist% - $num(%tracknumber%,2) - %title%))


When I see the preview in the 'edit file naming schemes' window, it shows up correctly. however, when i see the script in general mass renamer window, it starts with '[SYNTAX....]'. when i actually run the scheme anyway, my files get really weird. they go into a bunch of different directories. it is as if it is treating the if statement without any 'else' statements, catch me? it just tries to execute the whole thing.

what have i done wrong, ive not used $if in tagz statements yet. i checked the titleformatting help and i thought i had the format correct...$if(a,b,c) - a being '%album artist%, b being the naming scheme for such an album, and c being the naming scheme for files without 'album artist' data.

any pointers would be much appreciated as i havent used these $ifs before. thanks yall

edit: i have the 'use '/' and '\' characters' box checked. i normally do all my files this way, using two scripts. now im just seeing if i could make a smart script.
kjoonlee
Do you use 0.8.3 or 0.9? They treat path separators differently, IIRC.
foosion
The issue he reports clearly points to 0.8.3.

The problem is that the formatting script is split at / and \ before evaluation, though the preview does not reflect this, unfortunately. This is not the case for 0.9, so your code should work there (if you change it to respect field remappings). For 0.8.3, you can only use / and \ outside function argument lists and bracketed sections, so you have to evaluate each level of your directory hierarchy separately, like so:
CODE
$if(%album artist%,$caps2(%album artist%),$caps2(%artist%))\
$if(%album artist%,'('%date%')' $caps2(%album%),'('%date%')' $caps2(%album%))\
$if(%album artist%,$num(%tracknumber%,2) - $caps2(%artist% - %title%),$caps2(%artist% - $num(%tracknumber%,2) - %title%))

With a little clean-up applied this becomes
CODE
$caps2($if2(%album artist%,%artist%))\
'('%date%')' $caps2(%album%)\
$caps2($if(%album artist%,$num(%tracknumber%,2) - %artist% - %title%,%artist% - $num(%tracknumber%,2) - %title%))

" - %title%" could be moved out of the $if() in the last part, if you want to sacrifice clarity to shorten the code even more, but it is hardly worth it.

(Linebreaks included for readability.)
kenji idle
by the way,
with 0.83 you can create a string like this

%genre%\$if(%album%,%ablum%)\%title%

wich would result in metal\\track
if album is unknown

and masstagger will write the filename as metal\track

otherwise it would write it as

metal\album\track
XaiaX
QUOTE(kenji idle @ Feb 21 2006, 09:09 AM)
by the way,
with 0.83 you can create a string like this

%genre%\$if(%album%,%ablum%)\%title%

wich would result in metal\\track
if album is unknown

and masstagger will write the filename as metal\track

otherwise it would write it as

metal\album\track
*



You can also use "." and it will work because of the way Windows's file system works.

E.g., "cd .\.\.\.\.\.\.\.\windows" is the same as "cd windows"
NogginJ
thanks guys, i guess i am anxiously awaiting 0.9 more than i thought ;]. i just decided to use $if statements after reading the wonderful tutorial at brother john's site (although why he includes that confusing to a novice code about hex i will never understand ;]). his tutorial is written for 0.9.

if someone wouldnt mind, what would this intended code look like for 0.9, what with 'field remappings' and all....i dont really know exatly how they change things or what benefits they bring.

if not thanks anyway guys i will try out the code.
foosion
QUOTE(NogginJ @ Feb 21 2006, 10:01 PM)
if someone wouldnt mind, what would this intended code look like for 0.9, what with 'field remappings' and all....i dont really know exatly how they change things or what benefits they bring.
*

The following is roughly equivalent to the cleaned up version I posted previously.
CODE
$caps2(
$%album artist%\
'('%date%')' %album%\
$if($meta_test(album artist),%tracknumber% - %artist% - %title%,%artist% - %tracknumber% - %title%)
)
  • %album artist% is a remapped field and subsumes $if2($meta(album artist),$meta(artist).
  • %tracknumber% is the same as $meta(tracknumber,0), except that it pads the value to two digits with zeroes. You might still want to use $num(%tracknumber%,2) in case some tags have the form x/y, which would be neither padded nor truncated when you simply use %tracknumber%.
  • $meta_test(album artist) could be replaced by $track artist% which exists only when %album artist% and %artist% exist and have different values. In that case it has the same value as %artist%, though the script at hand does not make use of that.
  • Massrenamer evaluates the script as a whole without splitting at / and \ characters. If a tag contains characters that are not allowed in filenames, they will be replaced by "_" (underscore).
NogginJ
thanks for the info, the script works awesome.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.