Recursive Slideshow on Selected Folders

Overview

This is similar to the built-in Slideshow button, with the key difference that it handles directories recursively instead of only including the files directly below them.

  • If a file is selected explicitly, it will be included in the slideshow. (Regardless of file type.)

  • If a directory is selected, all files under it (including sub-directories, recursively) will be included, provided their extensions are in the Images file type group.

  • Multiple files/directories can be selected, and will be combined into a single slideshow.

  • If nothing is at all selected, all files in and below the current directory are included in the slideshow, provided their extensions are in the Images file type group.

(The Images file type group can be edited via Settings > File Types.)

Installation:

  • Download Slideshow (Recursive).dcf (2.6 KB)
  • In Opus, select Settings > Customize Toolbars.
  • Drag the downloaded file to your toolbars/menus where you want it.
  • Click OK in the Customize dialog to save the change.

Usage:

Similar to the built-in button, click it with nothing selected to show a slideshow of the current directory, or click it with a selection or files and/or folders to show a slideshow of them.

The slideshow delay, and whether it proceeds in order or randomly, is configured in Preferences, as with the standard Slideshow button.

History:

v1.0 (16-Sep-2023):

  • Initial version.

The script itself:

You don't need to read, understand or do anything with this if you just want to use it. Follow the installation steps above.

The script code is reproduced here to make it easier for people browsing the forum for scripting techniques.

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	cmd.ClearFiles();
	if (clickData.func.sourcetab.selected.count == 0)
	{
		// If nothing is selected, do the entire source directory (recursively).
		AddDir(cmd, clickData.func.sourcetab.path);
	}
	else
	{
		// If there's a selection, do the selected files and (recursively) folders.
		for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
		{
			if (eSel.item().is_dir)
			{
				AddDir(cmd, eSel.item().RealPath);
			}
			else
			{
				cmd.AddFile(eSel.item());
			}
		}
	}
	if (cmd.files.count == 0)
	{
		return;
	}
	cmd.RunCommand("Show SLIDESHOW");
}

function AddDir(cmd, dirPath)
{
	var folderEnum = DOpus.FSUtil.ReadDir(dirPath, "r");
	while (!folderEnum.complete)
	{
		var folderItem = folderEnum.Next();
		if (!folderItem.is_dir && folderItem.InGroup("Images"))
		{
			cmd.AddFile(folderItem);
		}
	}
}
3 Likes

what's the difference with this from year 2018??
Button: Recursive Slideshow

1 Like

Only minor details. I forgot I already wrote that. :smiley:

1 Like

Is there a way to display the images mixed?

The script could shuffle the list of images before sending them to the viewer. Not sure how complicated it would be to do off the top of my head.