GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Automatically move last downloaded file

Say I have folder "Pics" open in the lister and recently downloaded a file "01.jpg" into my "Download" folder. Is there a way for me make a button that will to automatically move the last file added to the "Download" folder into the "Pics" folder? (or into whatever folder is currently open in the lister?)

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;

	var newest = null;
	var folderEnum = DOpus.FSUtil.ReadDir("/downloads", false);

	while (!folderEnum.complete)
		var item =;
		if (!item.is_dir && != "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.RunCommand('Copy MOVE FILE="' + newest + '"');

Works great - thanks!

1 Like

Is there a way to modify this script so it only moves the most recently modified file if it was modified within the last 10 minutes? This would help me avoid moving files accidentally.


if (newest != null)


if (newest != null && DOpus.Create.Date() - newest.modify < 10 * 60 * 1000)

how about when a certain file type was created, so say only with .jpg files, never mind the date they where created