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.91a : 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.
IN /M When using Everything, this limits your search to the included folders only. It’s safe to pass files as well, since they’ll be filtered out.
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
[[
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.

  • You can tell the command to run an instruction per file instead of just once (the default) by appending 1, before the command. This is mostly needed for script/user commands rather than internal ones, as those automatically run for all files involved.

    LogicRun FILTER="my saved filter"
    [[
    COMMANDS
    1,MyCustomCommand1 ARGS
    $crlf
    1,MyCustomCommand2 ARGS
    ]]
    
  • If Everything is used, FILES arg is ignored.

  • You can only use FILTER or FILTERDEF, but not both.

  • When a FILTER is not included, all files pass through when exec instructions.

  • 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.91a (Jan 23, 2025): : LogicRun.opusscriptinstall (3.7 KB)

  • New IN argument, to specify folders to include when using Everything.
  • FILTER is no longer required to run the command. If not included, all files pass through.
  • Added an option to force instructions to execute per file instead of just once (mainly for script/user commands).
  • Other minor changes.

v0.9a (Jan 09, 2025):

  • 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.

v0.91a (Jan 23, 2025): :

  • New IN argument, to specify folders to include when using Everything.
  • FILTER is no longer required to run the command. If not included, all files pass through.
  • Added an option to force instructions to execute per file instead of just once (mainly for script/user commands).
  • Other minor changes.