GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Column: Kind and File Type Group


This script adds two columns, Kind and File Type Group. These are most useful for grouping and sorting.

For example, if you have assorted images and documents, using the built-in Type or Extension columns might result in something like:

  • BMP Images
  • DOC Documents
  • JPEG Images
  • PDF Documents
  • PNG Images

When what you want is:

  • Documents (DOC, PDF, etc.)
  • Images (BMP, JPEG, PNG, etc.)

The screenshot below is grouped by the script's Kind column. The script's Kind and File Type Group columns are displayed next to the built-in Ext (Dirs) and Type columns for comparison.

The script's two columns both serve the same purpose, but get their definitions from different places.

  • Kind is literally the Kind column you can use in File Explorer. If you just want what you're used to from Explorer, use this. Windows maps many file types to various Kinds by itself. Third-party software can also add its own file types to Kinds via registry settings and shell extensions.

    This column will only work on "real" files, not within things like archives.

  • File Type Group is specific to Opus, and lets you use the File Type Groups which you can edit via Settings > File Types. Out of the box, Opus defines File Type Groups for Archives, Documents, Images, Movies, Music and Programs. You can edit those groups to add and remove types from them, and you can also create your own custom groups.

    This column also has code to map directories to "Folder" and shortcuts to "Link". If you look at the code, you can remove or add to these, if you prefer to have mappings which are only defined in the script and do not modify the File Type Groups which are used elsewhere.

    This column will work almost everywhere, including within things like archives.

Installation and Usage:

Requires Directory Opus Pro 12.4 or above.

  • Download: Kind_Columns.js.txt (3.24 KB)
  • Open Settings > Preferences / Toolbars / Scripts.
  • Drag Kind_Columns.js.txt to the list of scripts.

Two new columns will now be available:

  • Script > Kind Columns > Kind
  • Script > Kind Columns > File Type Groups

You can display, sort and group using them the same 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.

This command will group by the Kind column (the column does not have to be displayed to group by it):

Set GROUPBY="scp:Kind Columns/Kind"

This command will add the File Type Group column and then sort by it:

Set COLUMNSADD="scp:Kind Columns/FileTypeGroup"
Set SORTBY="scp:Kind Columns/FileTypeGroup"

Known Issues:

  • The script can display a few strings which are hard-coded in English, but can be edited if you wish: "File Type Group", "Folder", "Link", "<Error>". Other strings should be translated via Windows or Opus, unless from third-party file types.


1.1 (08/Jan/2017):

  • If the Kind column cannot be generated, it now displays "<Error>" instead of generating an error in the script log.
  • Fixed display of user-defined File Type Groups.

1.0 (06/Jan/2017):

  • 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.

// Kind Columns
// This is a script for Directory Opus.
// See for development information.

// Called by Directory Opus to initialize the script
function OnInit(initData)
{ = "Kind Columns";
	initData.version = "1.1";
	initData.copyright = "(c) 2017 Leo Davidson";
	initData.url = "";
	initData.desc = "Columns for Opus's \"File Type Group\" and Explorer's \"Kind\", for grouping and sorting by high-level types (e.g. Pictures vs separate JPEG and PNG).";
	initData.default_enable = true;
	initData.min_version = "12.3";

	var col = initData.AddColumn(); = "FileTypeGroup";
	col.method = "OnFileTypeGroup";
	col.label = "File Type Group";
	col.justify = "left";
	col.autogroup = false;

	var props = DOpus.FSUtil.GetShellPropertyList("System.KindText", "r");
	if (props.count == 1)
		var prop = props(0);
		col = initData.AddColumn(); = "Kind";
		col.method = "OnKind";
		col.label = prop.display_name; // "Kind";
		col.justify = "left";
		col.autogroup = false;
		col.userdata = prop.pkey;

// Implement the FileTypeGroup column
function OnFileTypeGroup(scriptColData)
	if (scriptColData.item.is_dir)
		scriptColData.value = "Folder"; = "Folder";
	else if (scriptColData.item.ext == ".lnk")
		scriptColData.value = "Link"; = "Link";
		var groups = scriptColData.item.groups;

		if (typeof groups == "object")
			if (!groups.empty)
				if (groups.count == 1) // Speed up the usual, simple case.
					var strGroup = groups(0).display_name; = strGroup;
					scriptColData.value = strGroup;
					// Sort by group display names for consistent results.
					var vecGroupNames = DOpus.Create.Vector();
					for (var i = 0; i < groups.count; ++i)
					var strGroups = vecGroupNames(0);

					// Group by whatever comes first. There's usually only one group but no hierarchy if an extension is in more than one. = strGroups;

					// Add any other groups to the displayed value.			
					for (var i = 1; i < vecGroupNames.count; ++i)
						strGroups = strGroups + "; " + vecGroupNames(i);

					scriptColData.value = strGroups;

// Implement the Kind column
function OnKind(scriptColData)
	var strKind;
		strKind = scriptColData.item.shellprop(scriptColData.userdata);
	catch (e)
		scriptColData.value = "<Error>"; = "<Error>";

	if (typeof strKind == "string")
		scriptColData.value = strKind;

		// Kind can have multiple values, separated by ;, with the most significant one first:
		// Group by the first one, which also seems to be what Explorer does.

		var posSemi = strKind.indexOf(';');
		if (posSemi >= 0)
			strKind = strKind.substring(0, posSemi);
		} = strKind;
1 Like


This script seems to have an issue with user-created file type groups. In the File Types Dialog, I created two new groups:

Databases: .mdb, .accdb
Executables: .bat

When I view the File Type column, this is what I see:

I expect to see "Executables" for the bat file and "Databases" for the accdb file.


Root post updated with v1.1 which fixes that. Thanks for reporting it.