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.
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
IMPORTANT: Requires DOpus v13.14 or later
Download the file below. Then go to Script Management (or run Prefs SCRIPTINSTALL
) and select the downloaded file.
v0.99b : 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
If you use GETPROPS, this argument supports the same special syntax described in FILTERDEF.
Argument | Type | Value | Description |
---|---|---|---|
COMMANDS | /K/R | Specifies a list of commands to execute on the resulting files. | |
FILES | /M | Defines the files to use with the command. There are also predefined variables to refer to items in the current tab, where available: $all$ : All items in the source tab, including the hidden ones. $all_files$ : All files in the source tab, including the hidden ones. $all_dirs$ : All dirs in the source tab, including the hidden ones. $visible$ : All visible items in the source tab. $visible_files$ : All visible files in the source tab. $visible_dirs$ : All visible dirs in the source tab. $sel$ : All selected items in the source tab. $sel_files$ : All selected files in the source tab. $sel_dirs$ : All selected dirs in the source tab. $hidden$ : All hidden items in the source tab. |
|
FILTER | /O | Specifies the name of the saved filter to apply. | |
FILTERDEF | /K/R | Allows defining a filter textually. If you use GETPROPS, this argument supports special syntax to include column values from the desired files. To use a value, wrap it in $(value,separator,prefix,suffix)$, where: value is the exact Opus name of the column to use (including support for user columns like evaluator, script, or shell). sep is the string used to join values from each file. If omitted, it defaults to ; or OR, depending on context. prefix is an optional string added before each retrieved value. suffix is an optional string added after each retrieved value. Use a single quote (') to escape commas. E.g. =$(sizeauto, OR ,sizeauto_text==",")$ expands to =sizeauto_text=="107 KB" OR sizeauto_text=="80.1 KB" size:$(size)$ expands to size:109581;82024 See the Notes section for more details. |
|
GETPROPS | /M/O | A list of files from which values for columns defined in FILTERDEF or USEEVERYTHING can be retrieved. When used, but no files are specified, it will use the selected ones from the source filedisplay. |
|
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. | |
USEEVERYTHING | /K/R | Defines the Everything search query to retrieve 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
]]
You can also retrieve information from the files specified in GETPROPS
, and use it later in the filter.
Example: The following command will select all files in the current source filedisplay that match the sizes of the selected files.
LogicRun FILES $all$ GETPROPS {allfilepath$}
[[
FILTERDEF
=$(sizeauto, OR ,sizeauto_text==",")$
]]
[[
COMMANDS
Select FROMSCRIPT DESELECTNOMATCH
]]
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
orFILTERDEF
, 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.
-
When retrieving info from an item specified in
GETPROPS
, you can obtain almost any value, including user-defined columns.- To retrieve a value, use the corresponding column keyword or name. A list of built-in columns can be found here.
- If you plan to use
sizeauto
with Everything, it’s recommended to usesizeautoEV
instead, which contains the same info but without spaces.
Changelog
v0.99b (Apr 30, 2025): : LogicRun.opusscriptinstall (6.8 KB)
- Added new variables for
FILES
andGETPROPS
:$all_files$
,$all_dirs$
,$sel$
,$sel_dirs$
,$sel_files$
. - If
GETPROPS
does not specify any files, it will use the selected ones from the source file display.
Full changelog
v0.99a (Apr 30, 2025): :
- Added
GETPROPS
to specify files from which column values should be retrieved. - Now
FILES
supports variables ($all$
,$visible$
,$visible_files$
,$visible_dirs$
,$hidden$
) to reference files in the source tab. - Other minor fixes.
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.
v0.9a (Jan 09, 2025):
- Initial release.