Misc. audio-editing and -tagging commands

As asked for, here are a few (example) buttons for audio-editing for use within DirOpus. This is how I need them in my everday life, please change the commands yourself for your own needs. Also the additional tools used here offers lots of other options for more useful buttons.

Tools-source (all small and portable; default path for all commands is "/dopusdata\User Data\"):

Let's start...


Encode MP3 from WAV, FLAC or OGG in desired quality

Requires cmdline-tool "lame.exe", change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Encode_MP3</label>
	<tip>Convert FLAC/OGG/WAV to MP3</tip>
	<user_label>Encode MP3</user_label>
	<icon1>#play2</icon1>
	<function type="script">
		<instruction>@nodeselect </instruction>
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var dlg = clickData.func.Dlg();</instruction>
		<instruction>    dlg.window = clickData.func.sourcetab;</instruction>
		<instruction>    dlg.template = &apos;mydlg&apos;;</instruction>
		<instruction>    </instruction>
		<instruction>    var retVal = dlg.Show();</instruction>
		<instruction>    if (retVal == 1) var encVal = &apos;-b 320&apos;;</instruction>
		<instruction>    if (retVal == 2) var encVal = &apos;-b 160&apos;;</instruction>
		<instruction>    if (retVal == 3) var encVal = &apos;-b 128&apos;;</instruction>
		<instruction>    if (retVal == 4) var encVal = &apos;-V 0 --vbr-new&apos;;</instruction>
		<instruction>    if (retVal == 5) var encVal = &apos;-V 4 --vbr-new&apos;;</instruction>
		<instruction />
		<instruction>	cmd.deselect = false;</instruction>
		<instruction>    cmd.RunCommand(&apos;@sync: &quot;/dopusdata\\User Data\\Lame\\Lame.exe&quot; &apos; + encVal + &apos; &quot;{filepath$}&quot;&apos;);</instruction>
		<instruction>}</instruction>
		<instruction>==SCRIPT RESOURCES</instruction>
		<instruction>&lt;resources&gt;</instruction>
		<instruction>	&lt;resource name=&quot;mydlg&quot; type=&quot;dialog&quot;&gt;</instruction>
		<instruction>		&lt;dialog fontsize=&quot;8&quot; height=&quot;130&quot; lang=&quot;german&quot; title=&quot;MP3 encoden&quot; width=&quot;132&quot;&gt;</instruction>
		<instruction>			&lt;control halign=&quot;center&quot; height=&quot;8&quot; name=&quot;static1&quot; title=&quot;Please choose quality:&quot; type=&quot;static&quot; valign=&quot;top&quot; width=&quot;94&quot; x=&quot;19&quot; y=&quot;10&quot; /&gt;</instruction>
		<instruction>			&lt;control close=&quot;1&quot; height=&quot;14&quot; name=&quot;button1&quot; title=&quot;CBR 320 kbps (best)&quot; type=&quot;button&quot; width=&quot;101&quot; x=&quot;15&quot; y=&quot;30&quot; /&gt;</instruction>
		<instruction>			&lt;control close=&quot;2&quot; height=&quot;14&quot; name=&quot;button2&quot; title=&quot;CBR 160 kbps (medium)&quot; type=&quot;button&quot; width=&quot;101&quot; x=&quot;15&quot; y=&quot;48&quot; /&gt;</instruction>
		<instruction>			&lt;control close=&quot;3&quot; height=&quot;14&quot; name=&quot;button3&quot; title=&quot;CBR 128 kbps (web/mail)&quot; type=&quot;button&quot; width=&quot;101&quot; x=&quot;15&quot; y=&quot;66&quot; /&gt;</instruction>
		<instruction>			&lt;control close=&quot;4&quot; height=&quot;14&quot; name=&quot;button4&quot; title=&quot;VBR ~220 kbps (best)&quot; type=&quot;button&quot; width=&quot;101&quot; x=&quot;15&quot; y=&quot;84&quot; /&gt;</instruction>
		<instruction>			&lt;control close=&quot;5&quot; height=&quot;14&quot; name=&quot;button5&quot; title=&quot;VBR ~165 kbps (medium)&quot; type=&quot;button&quot; width=&quot;101&quot; x=&quot;15&quot; y=&quot;102&quot; /&gt;</instruction>
		<instruction>		&lt;/dialog&gt;</instruction>
		<instruction>	&lt;/resource&gt;</instruction>
		<instruction>&lt;/resources&gt;</instruction>
	</function>
</button>

Decode MP3 to WAV

Requires cmdline-tool "lame.exe", change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Decode MP3</label>
	<user_label>Decode MP3</user_label>
	<icon1>#play2</icon1>
	<function type="normal">
		<instruction>@nodeselect</instruction>
		<instruction>@sync: &quot;/dopusdata\User Data\Lame\Lame.exe&quot; --decode {filepath$}</instruction>
	</function>
</button>

Encode FLAC

Requires cmdline-tool "flac.exe", change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Encode_FLAC</label>
	<user_label>Encode FLAC</user_label>
	<icon1>#play2</icon1>
	<function type="normal">
		<instruction>@runmode hide</instruction>
		<instruction>@nodeselect</instruction>
		<instruction>@sync: &quot;/dopusdata\User Data\Flac\Flac.exe&quot; --best -m -e -r 6 -f -V {filepath$}</instruction>
	</function>
</button>

Decode FLAC

Requires cmdline-tool "flac.exe", change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Decode FLAC</label>
	<user_label>Decode FLAC</user_label>
	<icon1>#play2</icon1>
	<function type="normal">
		<instruction>@runmode hide</instruction>
		<instruction>@nodeselect</instruction>
		<instruction>@sync: &quot;/dopusdata\User Data\Flac\Flac.exe&quot; --decode {filepath$}</instruction>
	</function>
</button>

Tag from filename for MP3 and FLAC

Filename is "Artist - Title":

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Tag_(Artist-Title)</label>
	<tip>Insert metadata from filename (MP3 &amp; FLAC)</tip>
	<user_label>Tag (Artist - Title)</user_label>
	<icon1>#editmeta</icon1>
	<function type="normal">
		<instruction>@nodeselect</instruction>
		<instruction>Rename FILEINFO TO=&quot;{mp3artist}%{mp3title}&quot;</instruction>
		<instruction>@script vbscript</instruction>
		<instruction>Option Explicit</instruction>
		<instruction>Dim DOpusRTPath</instruction>
		<instruction>DOpusRTPath = &quot;C:\Program Files\Directory Opus\dopusrt.exe&quot;</instruction>
		<instruction>Dim Shell</instruction>
		<instruction>Set Shell = CreateObject(&quot;WScript.Shell&quot;)</instruction>
		<instruction>Function Rename_GetNewName ( strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName )</instruction>
		<instruction>    Dim re, strCommand, artist, title, path</instruction>
		<instruction>    Set re = new RegExp</instruction>
		<instruction>    re.Pattern = &quot;^(.*) - (.*)(\.mp3|\.flac)&quot;</instruction>
		<instruction>    artist = re.Replace(strFileName, &quot;$1&quot;)</instruction>
		<instruction>    title = re.Replace(strFileName, &quot;$2&quot;)</instruction>
		<instruction>    path = strFilePath &amp; &quot;\&quot; &amp; strFileName</instruction>
		<instruction>    strCommand = &quot;&quot;&quot;&quot; &amp; DOpusRTPath &amp; &quot;&quot;&quot; /cmd SetAttr &quot;&quot;&quot; &amp; path &amp; &quot;&quot;&quot; META &quot;&quot;artist:&quot; &amp; artist &amp; &quot;&quot;&quot; &quot;&quot;title:&quot; &amp; title &amp; &quot;&quot;&quot;&quot;</instruction>
		<instruction>    Shell.Run strCommand,0,false</instruction>
		<instruction>    Dopus.OutputString  &quot;Command: &quot; &amp; strCommand</instruction>
		<instruction>    strNewName = &quot;&quot;</instruction>
		<instruction>End Function</instruction>
	</function>
</button>

Filename is "Artist - Number - Title":

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Tag_(Artist-Number-Title)</label>
	<tip>Insert metadata from filename (MP3 &amp; FLAC)</tip>
	<user_label>Tag (Artist - Number - Title)</user_label>
	<icon1>#editmeta</icon1>
	<function type="normal">
		<instruction>@nodeselect</instruction>
		<instruction>Rename FILEINFO TO=&quot;{mp3artist}%{mp3track}%{mp3title}&quot;</instruction>
		<instruction>@script vbscript</instruction>
		<instruction>Option Explicit</instruction>
		<instruction>Dim DOpusRTPath</instruction>
		<instruction>DOpusRTPath = &quot;C:\Program Files\Directory Opus\dopusrt.exe&quot;</instruction>
		<instruction>Dim Shell</instruction>
		<instruction>Set Shell = CreateObject(&quot;WScript.Shell&quot;)</instruction>
		<instruction>Function Rename_GetNewName ( strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName )</instruction>
		<instruction>    Dim re, strCommand, artist, track, title, path</instruction>
		<instruction>    Set re = new RegExp</instruction>
		<instruction>    re.Pattern = &quot;(.*) - ([0-9]*) - (.*)(\.mp3|\.flac)&quot;</instruction>
		<instruction>    artist = re.Replace(strFileName, &quot;$1&quot;)</instruction>
		<instruction>    track = re.Replace(strFileName, &quot;$2&quot;)</instruction>
		<instruction>    title = re.Replace(strFileName, &quot;$3&quot;)</instruction>
		<instruction>    path = strFilePath &amp; &quot;\&quot; &amp; strFileName</instruction>
		<instruction>    strCommand = &quot;&quot;&quot;&quot; &amp; DOpusRTPath &amp; &quot;&quot;&quot; /cmd SetAttr &quot;&quot;&quot; &amp; path &amp; &quot;&quot;&quot; META &quot;&quot;artist:&quot; &amp; artist &amp; &quot;&quot;&quot; &quot;&quot;track:&quot; &amp; track &amp; &quot;&quot;&quot; &quot;&quot;title:&quot; &amp; title &amp; &quot;&quot;&quot;&quot;</instruction>
		<instruction>    Dopus.OutputString  &quot;Commande: &quot; &amp; strCommand</instruction>
		<instruction>    Shell.Run strCommand,0,false</instruction>
		<instruction>    strNewName = &quot;&quot;</instruction>
		<instruction>End Function</instruction>
	</function>
</button>

Filename is "Number - Artist - Title":

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Tag_(Number-Artist-Title)</label>
	<tip>Insert metadata from filename (MP3 &amp; FLAC)</tip>
	<user_label>Tag (Number - Artist - Title)</user_label>
	<icon1>#editmeta</icon1>
	<function type="normal">
		<instruction>@nodeselect</instruction>
		<instruction>Rename FILEINFO TO=&quot;{mp3track}%{mp3artist}%{mp3title}&quot;</instruction>
		<instruction>@script vbscript</instruction>
		<instruction>Option Explicit</instruction>
		<instruction>Dim DOpusRTPath</instruction>
		<instruction>DOpusRTPath = &quot;C:\Program Files\Directory Opus\dopusrt.exe&quot;</instruction>
		<instruction>Dim Shell</instruction>
		<instruction>Set Shell = CreateObject(&quot;WScript.Shell&quot;)</instruction>
		<instruction>Function Rename_GetNewName ( strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName )</instruction>
		<instruction>    Dim re, strCommand, artist, track, title, path</instruction>
		<instruction>    Set re = new RegExp</instruction>
		<instruction>    re.Pattern = &quot;([0-9]*) - (.*) - (.*)(\.mp3|\.flac)&quot;</instruction>
		<instruction>    track = re.Replace(strFileName, &quot;$1&quot;)</instruction>
		<instruction>    artist = re.Replace(strFileName, &quot;$2&quot;)</instruction>
		<instruction>    title = re.Replace(strFileName, &quot;$3&quot;)</instruction>
		<instruction>    path = strFilePath &amp; &quot;\&quot; &amp; strFileName</instruction>
		<instruction>    strCommand = &quot;&quot;&quot;&quot; &amp; DOpusRTPath &amp; &quot;&quot;&quot; /cmd SetAttr &quot;&quot;&quot; &amp; path &amp; &quot;&quot;&quot; META &quot;&quot;track:&quot; &amp; track &amp; &quot;&quot;&quot; &quot;&quot;artist:&quot; &amp; artist &amp; &quot;&quot;&quot; &quot;&quot;title:&quot; &amp; title &amp; &quot;&quot;&quot;&quot;</instruction>
		<instruction>    Dopus.OutputString  &quot;Commande: &quot; &amp; strCommand</instruction>
		<instruction>    Shell.Run strCommand,0,false</instruction>
		<instruction>    strNewName = &quot;&quot;</instruction>
		<instruction>End Function</instruction>
	</function>
</button>

Delete ALL tags from selected MP3-file(s)

Requires cmdline-tool "tag.exe", change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Delete_tags_MP3</label>
	<tip>Delete all tags from selected MP3-files</tip>
	<user_label>Delete MP3-tags</user_label>
	<icon1>#editmeta</icon1>
	<function type="normal">
		<instruction>@nodeselect</instruction>
		<instruction>@runmode hide</instruction>
		<instruction>&quot;/dopusdata\User Data\Tag\Tag.exe&quot; --remove {filepath}</instruction>
	</function>
</button>

Delete ALL tags from FLAC-file(s)

Requires cmdline-tool "metaflac.exe" (part of flac-archive), change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Delete_tags_FLAC</label>
	<tip>Delete all tags from selected FLAC-files</tip>
	<user_label>Delete FLAC-tags</user_label>
	<icon1>#editmeta</icon1>
	<function type="normal">
		<instruction>@runmode hide</instruction>
		<instruction>@nodeselect</instruction>
		<instruction>@sync: &quot;/dopusdata\User Data\Flac\Metaflac.exe&quot; --remove {filepath$}</instruction>
	</function>
</button>

Copy MP3-tags from one file to another

Requires cmdline-tool "id3.exe", change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Copy_tags_MP3</label>
	<tip>Copy MP3-tags from selected file to target file (dialogue)</tip>
	<user_label>Copy MP3-tags</user_label>
	<icon1>#editmeta</icon1>
	<function type="normal">
		<instruction>@set var = {dlgopen|Please select target file:|&quot;C:\&quot;}</instruction>
		<instruction>&quot;/dopusdata\User Data\ID3.exe&quot; -D &quot;{filepath}&quot; -2u {$var}</instruction>
	</function>
</button>

Add coverart to FLAC-file

Requires cmdline-tool "metaflac.exe" (part of flac-archive), change path to yours.

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Add_FLAC_coverart</label>
	<template>Adds selected Coverart to FLAC-file</template>
	<user_label>Add coverart to FLAC</user_label>
	<icon1>#imageconversion</icon1>
	<function type="normal">
		<instruction>@set var = {dlgopen|Please choose coverart:|&quot;C:\&quot;}</instruction>
		<instruction>&quot;your-path\metaflac.exe&quot; --import-picture-from=&quot;{$var}&quot; &quot;{filepath}&quot;</instruction>
	</function>
</button>

Create playlists from desired tags and select random size and number

*** These are just example scripts using tbone's SelectEX-script ***

Create playlist with all songs from 1980's, change year and 2 paths to yours:

var cmd = DOpus.Create.Command

// year 1980's
var jsFilter = ""+
          "if (item.metadata == 'audio'){ "+
                  "var year = new String(item.metadata.audio['mp3year']);"+
                  "if (year.indexOf('198')!=-1) return false;"+
          "}";
        cmd.RunCommand('Delete "coll://Playlist" REMOVECOLLECTION=auto QUIET')
          cmd.RunCommand('SelectEx LINEAR '+
                  'PATH="your-path" RECURSE JSFILTER="'+jsFilter+'" '+
				  'ITEMCOUNTPERC=100 '+
				  'COPYTOCOLL="Playlist" '+
                  'TOFILE="'+DOpus.FSUtil.Resolve('/your-path\\1980s.m3u'))

Create playlist with all songs from selected genres. Change, add or remove genres and 2 paths to yours:

var cmd = DOpus.Create.Command

// genre
var jsFilter = ""+
   "if (item.metadata == 'audio'){ "+
      "var genre = new String(item.metadata.audio['mp3genre']);"+
            "if ((genre.indexOf('Alternative')!=-1)"+
			"||(genre.indexOf('Disco')!=-1)"+
			"||(genre.indexOf('Electronic')!=-1)"+
			"||(genre.indexOf('New Age')!=-1)"+
			"||(genre.indexOf('Pop')!=-1))"+
            "return false;"+
            "}";
        cmd.RunCommand('Delete "coll://Playlist" REMOVECOLLECTION=auto QUIET')
          cmd.RunCommand('SelectEx LINEAR '+
                  'PATH="your-path" RECURSE JSFILTER="'+jsFilter+'" '+
				  'ITEMCOUNTPERC=100 '+
				  'COPYTOCOLL="Playlist" '+
                  'TOFILE="'+DOpus.FSUtil.Resolve('/your-path\\Pop.m3u'))

Select specified amount of random files in active lister (only MP3 or all files):

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>SelectEx_Random_Number</label>
	<tip>Select number of files randomly</tip>
	<user_label>Select number randomly</user_label>
	<icon1>#rename4</icon1>
	<function type="normal">
		<instruction>@set var = {dlgstringS|How many files would you like to select?}</instruction>
		<instruction>@set var2 = {dlgchoose|Choose filetype?:|All files= +MP3-files=NAME=&quot;\.mp3$&quot;}</instruction>
		<instruction>SelectEx RANDOM FILES {$var2} ITEMCOUNT={$var} DESELECTNOMATCH MAKEVISIBLE</instruction>
	</function>
</button>

Select specified MB's of random files in active lister (only MP3 or all files):

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>SelectEx_Random_Size</label>
	<tip>Randomize selected total file size</tip>
	<user_label>Select random size</user_label>
	<icon1>#rename4</icon1>
	<function type="normal">
		<instruction>@set var = {dlgstringS|Please enter total size to randomly select (in MB)?}</instruction>
		<instruction>@set var2 = {dlgchoose|Chosse filetype?:|All files= +MP3-files=NAME=&quot;\.mp3$&quot;}</instruction>
		<instruction>SelectEx RANDOM FILES {$var2} MAXSIZETOTAL={$var}MB ITEMCOUNT=999999 DESELECTNOMATCH MAKEVISIBLE</instruction>
	</function>
</button>
7 Likes

Thank you so much Sasa for sharing with us, I will must try every buttons. I think Copy MP3-tags from one file to another this button will be my most wanted button.

I use the "copy tags" in menu (via filetype): Right-click MP3 you want to copy tags from, select "copy tags" and then select target MP3 in target file dialog (starting in prefered path).

Hi Sasa I need more help about this button. I have download Tag.exe and extract in my windows folder


So my path is: C:\Windows\tag_2.0.52
then I copied your button (the button I have mention in this reply) code, then tried to paste into my Directory Opus toolbar but nothing happen, I can't paste your button code in to my toolbar.
then which part of the code should I changed for my path C:\Windows\tag_2.0.52

I can't tell you, why it doesn't work. Normally you just need to copy the code, set toolbar to edit-mode and insert the code in desired toolbar (it will appear as a new button then).

After this you need to edit the button and change the mentioned path to yours (search for <your path>).

1 Like

Can you please upload the DMC file

I think I've found the problemn... wait, I will fix it!

1 Like

I just loved your buttons, & wait for use it

So, I've updated all broken buttons and they should now be able to be copied into toolbar!

1 Like

Ok Sasa Now I can paste your button into my toolbar and It's works fine. but this button works for only one file at a time,

  1. Is there any way to copy multiple selected files tags from my source file display to paste same number of multiple files in my destination file display?
  2. This button's works only for mp3 to mp3 files, but I need FLAC to FLAC; MP3 to FLAC; FLAC to MP3
    is it possible sir?

No, but maybe someone could write a script to copy more than one.

For Flac please look at tools' options, as said, you can do lots more with them than I use here.

1 Like

Hi dear community can any one try to write a script about this!

Batch-copying metadata from an mp3-encoded album to its flac version makes sense and is quick as the files can easily be synced via their names, but how often do you really need to copy info between files that have completey different names and therefore require manual syncing?

Isn't that a really odd request, even by your standards?

Are you really eating all the food from the Opus buffet you are putting on your plate?

Or do you just like to order stuff because it's free?

2 Likes

I think you miss judge me.

This is what I want to do.

But the files have different file name, only the track no is the common between the mp3 and the flac version.
Let me try to make you convince!
I have all of my CD's MP3 and lower bitrate FLAC files Tagged version, Now this day's I have re ripped all of my CD's in High bitrate in Flac Lossless format. Newly Ripped Flac File Name is like track 1, track 2 where the old MP3 or flac version's has the real song's title as the file name like "My heart will go on". so filename's are not same. but the track no is common between (mp3/lower bitrate flac) and newly ripped higher bitrate flac version. So My Plane Open the (mp3/lower bitrate flac) version folder in my source file display, and newly Ripped Flac version folder opened in my Destination file display. then Select all mp3 files and press the button. the button will batch-coping the metadata from selected mp3 and paste to the Destination files. both file have common track no. so the track no 1.mp3 should be paste to track no 1.flac.... and same way all the track meta data should be syncing mp3 to flac files.
is copying full albums meta data (maybe 10 to 12 track's in a album)

...why not use tools like mp3tag?

My music-collection is almost complete and if I add a new album or few MP3s, I just want to do all things within DO (for example copy tags on MP3-replacement from one to another file). The buttons are for "normal" daily use. But for mass tagging I would always prefer tagging-tools.

Exactly. The copy-paste-functionality for tags is right there.

Yes, and mp3tag is for free.

Hi dear Sasa
I have tried so much time to use Filename is "Artist - Number - Title": this button but still it's not working. I have tried with mp3 and flac both file but it's not working. can you please recheck is the code ok? or can you please upload the button dcf file.
note: I have renamed my file as you say Artist - Number - Title with this pattern but still not working.

I've inserted the code from here to my Surface' Opus, which was never configured with these buttons and it works! See screenshot (hint: after using the command you have to refresh metaview to reload the written tags):

A .dcf will make no difference, it's exactly the same and with xml I'm able to change language to English.

1 Like

Yes! finally I found the Mistake I have made. I have just select Function : Script Function. This is the cause button doesn't works here for me. finally your buttons screenshot make me clear.
Thanks Sasa, Thank you so much.

Can you consider a little more help!
after tagging done I want to rename my File Name with the $3 capture group (title) of the Regex. can you add some line of code for that