Music tags sorted without articles


This script duplicates the built-in Artists, Album Artist, Album and Title columns for music metadata, adding alternative columns which display the same information but ignore articles ("The" and "A" by default) when sorting.

Not needed for the Name column

The ability to do this for the Name (filename) column is built-in. See the Ignore Prefix options under Folder Options and Global Filters to control that. You only need this script if you want something similar for other columns.

Installation and Usage:

Requires Directory Opus Pro 12.0 or above.

Several new column will now be available, categorised under:

  • Script > Music tags sorted without articles

You can display, sort and group using the columns as you would normal built-in columns. For example, right-click the column header, or use the Folder Options dialog.

You can also refer to the columns in commands which you can place on toolbar buttons, menu items, hotkeys, etc.

Changing the articles

The script applies a regular expression to remove the words "The" and "A" from the start of strings when sorting. You can change those words by modifying the regular expression. It is right at the top of the script:

// Regex to remove unwanted articles. Edit as needed.
var reFind = /^(The|A) (.+)$/;
var reReplace = "$2";


Grouping by the columns uses the default rules for script columns, and probably won't be useful compared to grouping by the built-in columns.

I'm not sure how grouping should work with these custom columns as it's not something I've ever wanted/needed. This is left as an exercise for the reader. :slight_smile:


1.1 (07/Sep/2020 later):

  • Columns should now auto-refresh when files are changed.

1.0 (07/Sep/2020):

  • Initial version.

Script code:

The script code from the download above is reproduced below. This is for people browsing the forum for scripting techniques. You do not need to care about this code if you just want to use the script.

// Regex to remove unwanted articles. Edit as needed.
var reFind = /^(The|A) (.+)$/;
var reReplace = "$2";

// Called by Directory Opus to initialize the script
function OnInit(initData)
{ = "Music tags sorted without articles";
	initData.version = "1.1";
	initData.copyright = "(c) 2020 Leo Davidson";
	initData.url = "";
	initData.desc = "Columns like music Artist which sort ignoring articles (The, A)";
	initData.default_enable = true;
	initData.min_version = "12.0";

// Called to add columns to Opus
function OnAddColumns(addColData)
	AddColumn(addColData, "Artists",     "Artists");
	AddColumn(addColData, "AlbumArtist", "Album Artist");
	AddColumn(addColData, "Album",       "Album");
	AddColumn(addColData, "Title",       "Title");

// Called to get the columns (all at once; multicol = true)
function OnColumns(scriptColData)
	var item = scriptColData.item;
	if (item.is_dir) return;
	var meta = item.metadata;
	if (meta != "audio") return;
	var audio =;

	for (var e = new Enumerator(scriptColData.columns); !e.atEnd(); e.moveNext())
		var colName = e.item();
		var colData = scriptColData.columns(colName);

		if      (colName == "Artists")     FillColumn(colData, audio.mp3artist);
		else if (colName == "AlbumArtist") FillColumn(colData, audio.mp3albumartist);
		else if (colName == "Album")       FillColumn(colData, audio.mp3album);
		else if (colName == "Title")       FillColumn(colData, audio.mp3title);

// Internal helper function
function AddColumn(addColData, colName, colLabel)
	var col = addColData.AddColumn(); = colName;
	col.method = "OnColumns";
	col.label = colLabel;
	col.justify = "left";
	col.autogroup = true;
	col.multicol = true;
	col.autorefresh = true;

// Internal helper function
function FillColumn(colData, tag)
	if (!tag || typeof(tag) != "string") return;

	var newTag = tag.replace(reFind, reReplace);

	colData.value = tag; // Display it as it was.
//	colData.value = newTag; // Display how it's sorted (for testing)
	colData.sort = newTag; // Sort it with the article removed.
	// TODO: Custom grouping if wanted for certain columns.

1.1 (07/Sep/2020 later):

  • Columns should now auto-refresh when files are changed.