GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Newest File column




This script provides columns which show the name and date of the newest file below each folder.

The script adds six columns. You'll only use one or two at a time.

Three of the columns report on files directly below each folder, ignoring sub-folders:

  • Newest File: Date and name.
  • Newest Date: Date only.
  • Newest Name: Name only.

The other columns report on files anywhere below each folder, including sub-folders:

  • Newest File (Recursive): Date and name.
  • Newest Date (Recursive): Date only.
  • Newest Name (Recursive): Name only.

The combined date and name columns let you turn on just one column to see both things, but the information is harder to read because the dates, times and filenames do not line up nicely. This isn't the case with the separate date and name columns. It's up to you which you use.

Sorting and grouping:

  • The combined columns sort by date/time and do not currently support grouping.
  • The date columns sort by date/time, and groups like the internal date columns do.
  • The name columns sort by name (alphabetically), and do not currently support grouping.

These columns read the list of files below each folder every time the file display is refreshed. For the recursive ones, that includes listing all sub-folders, and if you turn them on at the root of a drive the script will have to list every file on the drive. With large, complex directory trees, it can take a few seconds (and lots of disk/network activity) for the information to appear. You probably don't want to turn these columns on all the time, or in folders like C:. Use them when you need them and turn them off afterwards.


  • Download Newest File Column.js.txt (3.5 KB) v1.1
  • Open Preferences / Toolbars / Scripts to display the list of scripts.
  • Drag the downloaded Newest File Column.js.txt to the list.


  • v1.1 (15/Apr/2017)
    • "Subscript out of range" errors should be fixed now. They were due to this.
  • v1.0 (2014)
    • Initial version.


If the script is installed, you will see its columns under the Scripts category in the Folder Options dialog, or the menu you get from right-clicking your existing columns.

Add the columns manually as you would any others.

Alternatively, you might want to use a command, like this, which toggles a pair of the columns at once:

@ifset:COLUMNSTOGGLE="scp:Newest File Column/NewestFileDate"
Set COLUMNSREMOVE="scp:Newest File Column/NewestFileDate"
Set COLUMNSREMOVE="scp:Newest File Column/NewestFileName"
Set COLUMNSADD="scp:Newest File Column/NewestFileDate"
Set COLUMNSADD="scp:Newest File Column/NewestFileName"

The command editor's menus will work out the column names for you, so don't worry about doing that by hand.

The Script Itself

Expand the section below if you want to look at the script to see how it works.

The script

If you just want to use the script, the Newest_File_Column.js.txt download above is probably easier.

The script code is reproduced here so that people looking for scripting techniques on the forum can browse the script code without having to download and open the .js.txt file.

This script is in JScript.

// Newest File Column
// (C) 2014-2017 Leo Davidson
// This is a script for Directory Opus.
// See for development information.

function OnInit(initData)
{ = "Newest File Column";
	initData.desc = "Columns to show the newest file below each folder";
	initData.copyright = "(C) 2014-2017 Leo Davidson";
	initData.url = "";
	initData.version = "1.1";
	initData.default_enable = true;
	initData.min_version = "11.5.2"

	var col = initData.AddColumn(); = "NewestFile";
	col.method = "OnNewestFile";
	col.label = "Newest File";
//	col.header = "Newest File";
	col.justify = "left";
	col.autogroup = true;
	col.multicol = true;

	var col = initData.AddColumn(); = "NewestFileRec";
	col.method = "OnNewestFileRec";
	col.label = "Newest File (Recursive)";
	col.header = "Newest File (Rec)";
	col.justify = "left";
	col.autogroup = true;
	col.multicol = true;

	var col = initData.AddColumn(); = "NewestFileDate";
	col.method = "OnNewestFile";
	col.label = "Newest File Date";
	col.header = "Newest Date";
	col.justify = "right";
	col.autogroup = true;
	col.type = "datetime";
	col.multicol = true;

	var col = initData.AddColumn(); = "NewestFileDateRec";
	col.method = "OnNewestFileRec";
	col.label = "Newest File Date (Recursive)";
	col.header = "Newest Date (Rec)"
	col.justify = "right";
	col.autogroup = true;
	col.type = "datetime";
	col.multicol = true;

	var col = initData.AddColumn(); = "NewestFileName";
	col.method = "OnNewestFile";
	col.label = "Newest File Name";
	col.header = "Newest Name"
	col.justify = "left";
	col.autogroup = true;
	col.multicol = true;

	var col = initData.AddColumn(); = "NewestFileNameRec";
	col.method = "OnNewestFileRec";
	col.label = "Newest File Name (Recursive)";
	col.header = "Newest Name (Rec)"
	col.justify = "left";
	col.autogroup = true;
	col.multicol = true;

function OnNewestFile(scriptColData)
	NewestFileMain(scriptColData, false);

function OnNewestFileRec(scriptColData)
	NewestFileMain(scriptColData, true);

function BestItemName(item)
	if (item.display_name != "")
		return item.display_name;

function NewestFileMain(scriptColData, IsRecursive)
	if (scriptColData.item.is_dir)
		FolderEnum = DOpus.FSUtil.ReadDir(scriptColData.item, IsRecursive);

		NewestItem = null;

		while (!FolderEnum.complete)
			FolderItem =;

			if (!FolderItem.is_dir)
				if (NewestItem == null || NewestItem.modify.Compare(FolderItem.modify) < 0)
					NewestItem = FolderItem;

		if (NewestItem != null)
			var isRec = (IsRecursive ? "Rec" : "");

			if (scriptColData.columns.exists("NewestFileName" + isRec))
				scriptColData.columns("NewestFileName" + isRec).value = BestItemName(NewestItem) + "";

			if (scriptColData.columns.exists("NewestFileDate" + isRec))
				scriptColData.columns("NewestFileDate" + isRec).value = NewestItem.modify;

			if (scriptColData.columns.exists("NewestFile" + isRec))
				DateVar = new Date(NewestItem.modify);
				scriptColData.columns("NewestFile" + isRec).value = NewestItem.modify.Format() + " " + BestItemName(NewestItem);
				scriptColData.columns("NewestFile" + isRec).sort = DateVar.toJSON() + " " + BestItemName(NewestItem);

Copying folder timestamps
Prefix or Suffix Date to Folder
Support for dynamic column settings
Label Filter Stops Working After Restarting
Custom Context Menu commands: YOUR favorites?
Problems with SortBy, and a script question
Customizing Folder Columns
Average Filesize
Columns: Newest/Oldest filedate columns w/filtering
Columns: Maximum and Average File Size

Thanks Leo. :thumbsup:

This is a very useful addition to the ever growing arsenal of Opus goodies.

Regards, AB


It can't be changed to Chinese character, bad luck.


What can't be?


What can't be?[/quote]
Such as, "Newest File Column", "Newest File". If replaced by Chinese character, The script will go wrong.


It works fine. Make sure you save the script as UTF-8 with a BOM so the non-ASCII characters are saved correctly.

Notepad does the correct thing if you use the Encoding drop-down while saving.


I notice that errors occur on first use after Opus has started. I am using original @Leo script code and button code downloaded from the head post. No errors occur on second and subsequent executions. I had a look at the code and can't see anything untoward.

Error updated custom columns

I think that should be fixed now. Updated script in the root post. Please give it a try.


I want to label the newest file with a filter in current directory, it is very useful too.