This script add-in will make Directory Opus automatically select certain files when you go into certain folders.
You can configure the script to set the files and folders it reacts to. The folder paths can use wildcards.
To use the script, download the .vbs.txt file below, then drag and drop it to Preferences / Toolbars / Scripts, and click Configure on the new entry to set it up.
The script code is also reproduced here to help people looking through the forum for scripting techniques:
' Called by Directory Opus to initialize the script
Function OnInit(initData)
initData.name = "Special Auto-Select"
initData.desc = "Automatically select specific files when entering certain folders."
initData.copyright = ""
initData.version = "1.1"
initData.default_enable = true
Set vecDefFolders = DOpus.Create.Vector
' Default folders / example config.
vecDefFolders.push_back("*\Directory Opus :: dopus.exe")
vecDefFolders.push_back("*\Outlook :: Outlook.pst")
vecDefFolders.push_back("C:\Passwords :: File4.txt")
initData.config.FolderPatterns = vecDefFolders
Set mapDescs = DOpus.Create.Map
mapDescs("FolderPatterns") = "Folder path wildcards and files to select. Put :: between the wildcard and the filename. Example: ""*\Directory Opus :: dopus.exe"" selects ""dopus.exe"" when you go into any folder called ""Directory Opus""."
initData.config_desc = mapDescs
End Function
' Called after a new folder is read in a tab
Function OnAfterFolderChange(afterFolderChangeData)
For Each configPattern in Script.config.FolderPatterns
configSplit = Split(configPattern, "::", 2)
Set folderPattern = DOpus.FSUtil.NewWild( trim( configSplit(0) ) )
If (folderPattern.Match(afterFolderChangeData.tab.path)) Then
Set cmd = DOpus.Create.Command()
cmd.SetSourceTab afterFolderChangeData.tab
cmd.RunCommand "Select PATTERN=""" & trim( configSplit(1) ) & """ EXACT SETFOCUS DESELECTNOMATCH"
Exit Function
End If
Next
End Function
Maybe use SelectEx: Command: SelectEx (extended Select command)
It supports folders and files, regexes for both (path and item) and will scroll to any auto-selected item as well (if enabled). Watch the "Auto-Selection" description at the bottom and the AUTO cmdline switch.
Yes, that also looks very promising. However, i couldn't get it to work for some reason.
i use follwowing syntax: C:\Program Files\VideoLAN\VLC => vlc.exe
There's also this script error message.
SelectEx: Fehler in Zeile 671, Position 3
SelectEx: Unerwarteter Quantifizierer (0x800a139a)
By the way, i already played around with your very interesting script, and saved some selections. Is it normal, that it would remember saved selections only for one Opus session, using "save selection toundfrom" a file?
Leo, you're right. I had a typo (missing blank space after : in the old list of paths and applications, which must have caused that red error icon. So, all is fine.
This script is great! However when the file is auto-selected it does not preview in the viewer pane until manually selected. Is there a way to have the file both auto-selected and previewed?