Find & replace composers & artist metadata in FLAC files?

Hi DOpus forum
I am very new, so forgave me if I want anything what's not possible.
I need a advanced find and replace dialog box. the dialog box should have two combo list for search and replace in composers and artist column. From where I can find something in composers or artist columns (which one I have select from the combo list) meta data of selected multiple flac files; then can replace with something. Thanks.

1 Like

It could be done via scripting, but there's nothing built-in which would do that.

1 Like

It is very very useful to me. So it's my humble request to you, please give me a scripting button for do that.

Best Regards

Hi leo
Am I on your to do list? this button is very useful for me as well as for others I believe.

We can’t promise to write complete custom scripts. We can help if you have questions about how to write them.

2 Likes

How to write them in JavaScript?
I am Here

Ok I have Create a Dialog box as I want & write some script line for show the dialog box.

function OnClick(clickData)
{
var Dlg = DOpus.Dlg;
    Dlg.window = clickData.func.sourcetab;
    Dlg.template = "Advanced Find and Replace";
    Dlg.Show();	

	if (Dlg.result) {
		var FindWhat = Dlg.control("Find what").value.name;
		var FindIn = Dlg.control("Find in").value.name;
		}
		
}

The Resources is:

<resources>
	<resource name="Advanced Find and Replace" type="dialog">
		<dialog fontsize="8" height="100" lang="english" width="180" resize="yes" standard_buttons="ok,cancel" title="Advanced Find and Replace">

			<control halign="left" height="8" name="LabelforFind in" title="Find in" type="static" valign="top" width="40" x="6" y="6" />
			<control height="40" name="Find in" sort="yes" type="combo" width="64" x="78" y="6">
				<contents>
					<item text="Composers" />
					<item text="Album" />
					<item text="Artist" />
					<item text="Album Artist" />
					<item text="Gener" />
					<item text="Publisher" />
				</contents>
			</control>
			<control halign="left" height="8" name="Find what" title="Find what" type="static" valign="top" width="42" x="6" y="30" />
			<control halign="left" height="12" name="Find what" title="Find what" type="edit" width="64" x="78" y="30" />
			<control halign="left" height="8" name="Replace with" title="Replace with" type="static" valign="top" width="48" x="6" y="54" />
			<control halign="left" height="12" name="Replace with" title="Replace with" type="edit" width="64" x="78" y="54" />
		</dialog>
	</resource>
</resources>

Now I need some code for link up each button of the dialog box with the internal metadata. I mean when I select Composers Item form the list, then should be works in composers meta data filed of selected files.

The item object for each file has a metadata property/object for extracting metadata. As well as what’s in the manual, you can find several examples of how to use it on the forum. The Buttons & Scripts area has a metadata tag on posts which use it, which will find several examples.

1 Like


There is only 2 post with the metadata tag and both is most complex for me. I am not able to extract that code. can you please write some code or give some example post link where use find and replace method for any music metadata in JavaScript. Thanks.
NB: If you have not enough time now no problem, I can wait, then just tell me I am no your to do list.

Grab a copy of Mp3tag. Find&Replace is part of its main features.

Replace strings in tags and filenames (with support for Regular Expressions).

I thought there were more, but there are definitely more examples on the forum if you search for something that would appear in the relevant code like ".metadata". Searching for that, the first result is a FAQ about extracting metadata using scripts:

1 Like

Ok here is my improvment

function OnClick(clickData){

	var cmd = clickData.func.command;
		cmd.deselect = false; // Prevent automatic deselection

	var Dlg = DOpus.Dlg;
    	Dlg.window = clickData.func.sourcetab;
    	Dlg.template = "Advanced Find and Replace";
    	Dlg.Show();	

		
	if (Dlg.result) {
		var FindIn = Dlg.control("Find in").value.name;
		var FindWhat = Dlg.control("Find what").value.name;
		var Replacewith = Dlg.control("Replacewith").value.name;
//Here need something to check the selected files " META "composers: with the value of 'var FindWhat'
//then need a If condition; if matched then replace with that matched part by the value 'var Replacewith'
//then store the new value to a new variable name 'var ReplacedComposers = <value>'

//var ReplacedComposers = <value>;
		
				
		}

for (var enumSelected = new Enumerator(clickData.func.sourcetab.selected_files);!enumSelected.atEnd();enumSelected.moveNext()) {
		cmd.RunCommand('SetAttr "'+enumSelected.item()+'" META "composers:' + ReplacedComposers + '"');		
	}
	}

Hi Leo Need a little more line of code. Please write some lines of code.
Here need something to check the selected files " META "composers: with the value of 'var FindWhat'
then need a If condition; if matched then replace with that matched part by the value 'var Replacewith'
then store the new value to a new variable name 'var ReplacedComposers = '

1 Like

The post I linked to shows how to get metadata out of files. But if you're having this much trouble writing a script to do this, why not use mp3tag as Lxp suggested above? It's free and has built-in support for what you want to do. It'll be quicker to use that.

I need some post where I can get a find and replace code, the post you have linked here there is nothing I found where use find and replace technic.
I am surprise am I on a mp3tag forum? or are you associate with mp3tag program? why everyone imposed me to use another program when I think I am on DOpus forum.
I am a new user and this is my first post here. I saw you have write so many code (many of them are completely customize script ) for so many user in this forum before. I am also a Pro user. But you didn't write a single line of code in my post. why? I tell you if you short of time you can tell me for wait, but you do not tell me that you just suggested another program for use.
Regards

The Opus licence fee doesn't include a personal script writing service. The reason someone suggested mp3tag is because it's a way to solve your problem that doesn't involve writing scripts. If you want to do it with an Opus script, you'll have to write it yourself.

Yes I know that, I just said there are some customized script in this forum for some users, are they pay extra for that? I have tried to write the script as much as I can, some lines of codes I need what I can't write, on that case I just want a little help from you guys. That's it. I saw in many post in this forum you guys wrote this kinds of codes for many other users. that's why I expect same response here in my post.

If you are just looking to replace fields with another one you can do it with mp3tag, it's full GUI so it might be simpler for you.

Mp3tag is bit slow though in comparison to a dopus script or powershell at tagging files but for audio you should be okay.

Thanks, but I don't want to replace fields with another one. I want to simple search in composers field for a searching key string, then If it matched with any selected files composers field then replace with another string. as we use find and replace in MS Word.
Example: 01. this is a demo file name.flac and this files composer field have this meta data aaa bbb ccc ddd I want to replace the ccc string part with eee. so I need to create a scripting button which will search in composers fields for the string part ccc If matched then replace that part with eee. So the final result is the composers metadata will be aaa bbb eee ddd

You can do that as well check your messages for screenshots, you can replace just a part of the artist tag and even use regular expressions for more complex stuff if you want. It works similar to the find and replace in ms word.

The only added step would be that you would have to drag and drop the files you want to edit instead of just selecting them and pushing a button on dopus.

You can also combine dopus with command line tools like taglibsharp or id3tags console but that would require some scripting.