You could let an event do the check and set a variable:
function OnInit(initData) {
initData.name = 'CheckPathAndSetVar';
initData.version = '2023-08-31';
initData.url = 'https://resource.dopus.com/t/disable-toolbar-button-if-source-path-does-not-exist/45640';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnAfterFolderChange(afterFolderChangeData) {
if (!afterFolderChangeData.result) return;
var tab = afterFolderChangeData.tab;
if (!tab) return;
var item = tab.path + '~snapshot';
if (DOpus.FSUtil().Exists(item)) {
tab.vars.Set('snapshotVar', 1);
} else {
tab.vars.Delete('snapshotVar');
}
}
The button would start like this:
@disableif:!$tab:snapshotVar
Save EventCheckPathAndSetVar.js.txt to
%appdata%\GPSoftware\Directory Opus\Script AddIns