This will do that, based on the files' modified timestamps.
(If that doesn't work, using the created timestamps might work better, depending on what's making the downloaded files and how it's managing the two timestamps.)
It uses the system Downloads folder (/downloads
alias in Opus) but you can change that near the top if needed.
Script for reference:
function OnClick(clickData)
{
var cmd = clickData.func.command;
cmd.deselect = false;
cmd.ClearFiles();
var newest = null;
var folderEnum = DOpus.FSUtil.ReadDir("/downloads", false);
while (!folderEnum.complete)
{
var item = folderEnum.next;
if (!item.is_dir && item.name != "desktop.ini")
{
if (newest == null || newest.modify.Compare(item.modify) < 0)
{
newest = item;
}
}
}
if (newest != null)
{
// "Copy HERE" doesn't work with scripting; use SetDestTab instead.
cmd.SetDestTab(cmd.sourcetab);
cmd.RunCommand('Copy MOVE FILE="' + newest + '"');
}
}