How to write to mp3 tags with a Button

i only get the first word with SetAttr META contentgroup:Studio Album

You were close with the quotes, but they need to enclose the keyword as well as the value.

SetAttr META "contentgroup:Studio Album"

GREAT SetAttr META "contentgroup:Studio Album" WORKED so now how to add more then one contentgroup to the same set of files ? say Christmas Album

i tried SetAttr META "contentgroup:Studio Album" ; "Christmas Album"

great it worked in the end like this SetAttr META "contentgroup:Studio Album";Christmas Album

so now the same album shows in Studio Album and in Christmas Album

not quite there yet for two types yet SetAttr META "contentgroup:Studio Album";Christmas Album with this i get the two groups but Studio Album shows as Studio Album" with a " on the end

Try moving the quote to the end of the whole thing.

cool that was it thank you

got things working but now want to add a bit more
let say i have albums like this

Music\A\abba\cool songs\cd1
Music\A\abba\cool songs\cd2
Music\A\abba\best of \cd1
Music\A\abba\best of \cd2

and iam working in the abba folder

i have the the folders selected that are Compilation Albums

my button so far

1 Select *.mp3
2 SetAttr META "contentgroup:Compilation Album"

what to add to get this to work inside folders with out going in to them .. so do this to all Selected folders

This script button could work, you need the SelectEx script addin to be installed for the button to work in some way at all. Find it here: Command: SelectEx (extended Select command)

var doCommand = 'SetAttr META "contentgroup:Compilation Album"';

function OnClick(data){
	var cmd = data.func.command, srctab = data.func.sourcetab;
	var cmdTmp = DOpus.Create.Command();
	srctab.Vars.Set("SexRes") = "";
	for(var d=0;d<srctab.selected_dirs.count;d++) {
		var folderItem = srctab.selected_dirs(d);
		DOpus.Output("Scanning folder ["+folderItem.name+"]..");
		cmd.RunCommand(	'SelectEx LINEAR FILES NAME=".+\.mp3$" PATH="'+folderItem.realpath+'" '+
						'ITEMCOUNTPERC=100 RECURSE SETVAR="SexRes" ECHO');
		var strItems = srctab.Vars.Get("SexRes"); if (strItems=="") continue;
		var arrItems = strItems.split("\r\n"); 
		for(var i=0;i<arrItems.length;i++)
			cmdTmp.AddFile(arrItems[i]);
	}
	if (cmdTmp.filecount) cmdTmp.RunCommand(doCommand);
	DOpus.Output("Done.");
}
1 Like

Don’t you want the RunCommand outside the for loop?

Yes we do! Fixed it, thank you. o)

1 Like

i tried the script button but it gives me an error

i have SelectEx script installed
an error occurred setting metadata

metadata parsing error

What is the error?

an error occurred setting metadata

metadata parsing error

Sorry wobbly, I did this very quickly by copying and pasting together some older button parts aaand.. I had no mp3-file around for testing (being at work.. o).

I now managed to test it with actual mp3 files in some folders and it works. I've fixed the code above once more, so please re-copy&paste into your button and try again. o)

great that worked this time ... and iam happy you got it wrong now i can have a look and try and work out why the old one did not work :slight_smile:

thank you very much everyone :heart_eyes:

No, it's not worth looking into it! o) It was the call to .split("\n") causing issues, because I had changed the separator to be "\r\n" at some point in SelectEx. Sorry for the mess, could think of various ways to enhance this, but for now you probably have something to work with.

You could also just use DOs FSUtils.ReadDir() in recursive mode to get your items. Using SelectEx might not be the most straightforward attempt here. So in case you experience performance- or other kind of issues, you still have some options. o)

great it worked in the end like this SetAttr META "contentgroup:Studio Album";Christmas Album

so now the same album shows in Studio Album and in Christmas Album
[/quote]

is there a way to have a list a say ALBUM types eg Christmas 80's Rock and so on ...and them pick from a list
the album types you want to set you might want one or many thanks

say with a check box for options for album type(s) ?