LogicRun Command : Streamlined filtering and execution combined

LogicRun is a script addin command for Directory Opus that allows you to implement filtering functionality for any command, enabling selective execution.

How This Works

The command lets you easily apply a filter (textbased or a saved template) to files (selected, explicitly named, or retrieved via an Everything search filter) and execute other commands on the resulting set.

:warning: IMPORTANT: READ BEFORE PROCEEDING

This script is provided "as is" and without any kind of warranty.
It was developed during my spare time and has not been extensively tested, so it is presented as a testing version.
The user assumes full responsibility for its use and acknowledges that the author is not liable for any failures or data loss.
Please note this is a work in progress, so bugs may occur.
Feedback on possible improvements or bug reports is highly appreciated.

How to Install

:warning: IMPORTANT: Requires DOpus v13.12.3 or later
Download the file below. Then go to Script Management (or run Prefs SCRIPTINSTALL) and select the downloaded file.

v0.9a : LogicRun.opusscriptinstall

Options

In the Script Management window, select LogicRun and click the Edit button.

log level: Logging level to display.
Everything max timeout: Maximum wait time for Everything results, in milliseconds.

Usage

LogicRun supports the following arguments:

Command Arguments

Argument Type Value Description
FILES /M Defines the files to use with the command.
FILTER /O Specifies the name of the saved filter to apply.
USEEVERYTHING /K/R Defines the Everything search query to retrieve files.
FILTERDEF /K/R Allows defining a filter textually.
COMMANDS /K/R Specifies a list of commands to execute on the resulting files.

To use this command, it is recommended to split the instruction into multiple lines using the multiline syntax [[ ]].

Example: The following command adds the tag "animals" to all JPG and PNG files created this month that already have the "cat" tag. It also copies the affected files to the "Animals" collection:

LogicRun DUMMY
[[
FILTERDEF
=Match(keywords,"cat","p")
]]
[[
USEEVERYTHING
ext:jpg;png dc:thismonth
]]
[[
COMMANDS
SetAttr META "tags:+animals"
$crlf
Copy COPYTOCOLL=member CREATEFOLDER "coll://Animals" WHENEXISTS=skip
]]

Alternatively, a previously saved filter in Preferences can be used.

Example: The following command runs MyCustomCommand1 and MyCustomCommand2 on selected files in the source pane that match the "my saved filter" template:

LogicRun FILTER="my saved filter"
[[
COMMANDS
MyCustomCommand1 ARGS
$crlf
MyCustomCommand2 ARGS
]]

Notes / Technical Details

  • When using multiline syntax in the COMMANDS argument, use $crlf for line breaks to define multiple commands.
  • If multiline syntax is used and LogicRun appears alone on a line, add a placeholder (e.g., DUMMY) to ensure proper parsing.
  • If Everything is used, FILES arg is ignored.
  • You can only use FILTER or FILTERDEF, but not both.
  • Max results from Everything is ruled by everything_max_results advanced Preferences value.
  • If Everything is used and it is configured for autostart but not currently running, it will be opened and closed automatically.

Changelog

v0.9a (Jan 09, 2025): LogicRun.opusscriptinstall (3.3 KB)

  • Initial release.
5 Likes

As promised, here's a preview version, which will hopefully be useful for Opus users.
Initially, when it was just for my personal use, many options were hardcoded. Removing them and adding new features so is more user-friendly, might have introduced some bugs. Please let me know if you find any.