Greetings,
I want to make a button, to automatically set the title of my musics.
I want to use a regular expression (entered using a dialog box) to evaluate the title, and then use :
SetAttr META title:
How can I set a variable with the result of a regex, please ?
Pfff I'm really sorry, it works perfectly now, I just selected "Script function" instead of "standard function (opus or external)".
If someone comes here, a little more help would be welcome
I would like to count the number of mp3 in the folder, and the replace the meta track from 1, to 1/10 for example.
I overhauled the code a bit as it made use of the outdated rename-script hack, while also using the external dopusrt.exe to run required actions. The latter isn't the suggested way either, so here you get something v11 complaint. o)
This reads the track from the filename and sets the track-meta to "/".
Be aware that your files need to have track information that matches the regexp, track numbers must also be less/equal than the total number of files selected. So this won't work on a filename containing track index 9 and only 6 files selected. The SetAttr command seems to validate the input, what a clever beast! o)
@script jscript
function OnClick(data){
var files = data.func.sourcetab.selected_files;
var cmd = data.func.command; cmd.ClearFiles();
var re = new RegExp("(.*?) (.*)(\\.mp3)");
for(var i=0;i<files.count;i++){
DOpus.Output("File: [" + files(i).name+"]");
var matches = String(files(i).name).match(re);
if (!matches){ DOpus.Output(" skipped"); continue; }
var track = matches[1]; //var title = matches[2];
var cmdli = 'SetAttr META="track:'+track+'/'+files.count+'" FILE="'+files(i).realpath+'"';
DOpus.Output(" cmd: " + cmdli);
cmd.RunCommand(cmdli);
}
}