Auto Commands For Specific Folders
I've created a versatile add-in script that automates executing different arbitrary commands for different corresponding specified folder paths, including with wildcards and several other features.
Features:
Commands
- Set any number of path-command pairs with one script
- Run a command upon entering a specific folder path
- Specify an optional leave command in addition to entry command
- Supports exact paths, wildcards, aliases, and windows environment variables
Smart Execution
- Works whether navigating into a matching folder, or switching to a matching tab
- Leave command will only trigger when entering a non-matching folder, or switching to a non-matching tab
- For example, if entering sub-folders of a wildcarded path, it won't re-execute every time (unless optional switch is enabled)
- Optional switches to always run "entry" and/or "leave" command when entering a matched path, even if already coming from a matched path.
- Switches individually enabled/disabled for each path
Example Use Case:
- Automatically opening a toolbar when entering a specific folder or path, and closing it when leaving the folder or switching to a different tab
- Automatically enabling Flat View within a certain folder
- Anything else that can't already be accomplished via a custom folder format
- Redirecting from library "lib://" paths to their true drive path (See Example)
Usage:
Open the FolderCommandPairs
config setting and enter any number of path-command groups with the following format:
PathX = <folder_path>
EntryCommandX = <command_to_run_on_entry>
LeaveCommandX = <command_to_run_on_leave>
SwitchesX = <comma_separated_switches>
Where:
- X is a number (1, 2, 3, etc.) to group related commands
- Available switches: AlwaysRunEntry, AlwaysRunLeave, DontResolvePath
--AlwaysRunEntry
,AlwaysRunLeave
: Lets you run the entry/leave commands even when the next folder also matches the rule.
--DontResolvePath
: The given path will not be resolved before being checked against the lister path. May be necessary for paths like lib:// which would be re-written as C:\Users... and therefore might not match when expected. (Detailed Explanation here)
Other Config Notes:
- The folder path can include wildcards (*), folder aliases, and Windows environment variables
- Commands can even include built-in Opus function arguments like
{sourcepath}
- Lines starting with // are treated as comments. Empty lines are also ignored.
LeaveCommand
andSwitches
are optional and need not be included.
Installation
- Download AutoFolderCommand.vbs.txt (20.4 KB)
- Open the Script Management window (Main Toolbar > Settings > Scripts)
- Drag the downloaded AutoFolderCommand.vbs.txt to the list.
- In the Script Management window, click the Gear to open the config settings
Note: It's probably necessary to temporarily enable the DisableCache
option after changing the FolderCommandPairs
config for changes to take effect. Restarting Opus would work too.
Examples / Screenshots
Example Config (The script does have an example config set by default)
Config Window
Changelog:
- 1.0.0 → 1.1.0:
- Added "DontResolvePath" switch
- Added note that standard function command arguments can be included in commands