' 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