Button: Recursive Slideshow

Overview:

Opus's default toolbar has a Slideshow button which runs the built-in Show SLIDESHOW command.

The built-in command works on either the whole current directory or the selected files and folders, if any.

When a folder is selected, the built-in command adds the images directly below the folder to the slideshow, but it does not recurse into sub-directories.

The button/script below is similar, except that it will recurse into sub-directories and find all files either below the current folder (if nothing is selected) or below the selected folders (if anything is selected).

Installation:

This requires Directory Opus Pro 12.9.4 or above. You'll get an error if you use it on earlier versions.

  • Download Slideshow (recursive).dcf (2.8 KB).
  • Use Settings > Customize Toolbars to enter Customize mode.
  • Drag the downloaded .dcf file to your toolbar.

For more detailed instructions, see: How to use buttons and scripts from this forum

Usage:

Similar to the standard Slideshow button, click it in a folder with nothing selected to show everything in (and below) the current folder. Or click it with some files and/or folders selected to show only those files and the files below those folders.

Slideshow speed can be configured under Preferences / Viewer / Behavior.

History:

  • 1.0 (30/Sep/2018): 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.

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.ClearFiles();

	var fsu = DOpus.FSUtil();

	var itemsToEnum = clickData.func.sourcetab.selected;
	if (itemsToEnum.count == 0)
	{
		itemsToEnum = clickData.func.sourcetab.all;
	}

	// Add to a fileSet instead of directly into the Command object, as otherwise
	// you can get duplicate files when Flat View is turned on.
	var fileSet = DOpus.Create.StringSetI();

	for (var eSel = new Enumerator(itemsToEnum); !eSel.atEnd(); eSel.moveNext())
	{
		var item = eSel.item();

		if (!item.is_dir && item.InGroup("Images"))	
		{
			fileSet.insert(item.RealPath);
		}
		else if (item.is_dir)
		{
			var folderEnum = fsu.ReadDir(item.RealPath, true); // Recursive
			while (!folderEnum.complete)
			{
				var subItem = folderEnum.Next();
				if (!subItem.is_dir && subItem.InGroup("Images"))
				{
					fileSet.insert(subItem.RealPath);
				}
			}
		}
	}

	if (fileSet.count > 0)
	{
		for (var eFile = new Enumerator(fileSet); !eFile.atEnd(); eFile.moveNext())
		{
			cmd.AddFile(eFile.item());
		}
		cmd.RunCommand("Show SLIDESHOW FULLSCREEN");
	}
}
3 Likes