How to write to mp3 tags with a Button

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