function OnInit(initData) { initData.name = 'WatchOutlookMsg'; initData.version = '2024-11-20'; initData.url = 'https://resource.dopus.com/t/rename-using-metadata-from-outlook-msg-files/39930/27'; initData.desc = 'WatchOutlookMsg'; initData.default_enable = true; initData.min_version = '13.0'; } function OnAddCommands(addCmdData) { var cmd = addCmdData.AddCommand(); cmd.name = 'WatchOutlookMsgStart'; cmd.method = 'OnWatchOutlookMsgStart'; cmd.desc = 'WatchOutlookMsgStart'; cmd.label = 'WatchOutlookMsgStart'; cmd.template = ''; cmd.hide = false; cmd.icon = 'script'; var cmd = addCmdData.AddCommand(); cmd.name = 'WatchOutlookMsgStop'; cmd.method = 'OnWatchOutlookMsgStop'; cmd.desc = 'WatchOutlookMsgStop'; cmd.label = 'WatchOutlookMsgStop'; cmd.template = ''; cmd.hide = false; cmd.icon = 'script'; } var fsu = DOpus.FSUtil(); var itemID = 'RenameOutlookMsg'; function OnWatchOutlookMsgStart(scriptCmdData) { var item = fsu.GetItem(fsu.Resolve('D:\\MyOutlookMsgInboxFolder')); fsu.WatchChanges(itemID, item, 'f'); // monitor for file change in folder (e.g. file created) DOpus.Output('Started monitoring'); } function OnWatchOutlookMsgStop(scriptCmdData) { fsu.CancelWatchChanges(itemID); DOpus.Output('Stopped monitoring'); } function OnFilesystemChange(FilesystemChangeData) { if (FilesystemChangeData.id != itemID) return; // Note that you aren't told what changed, only that something meeting the specified conditions did change. DOpus.Output('Action!'); var cmd = DOpus.Create().Command(); var cmdLine = 'Rename PRESET=Email'; DOpus.Output(cmdLine); // cmd.RunCommand(cmdLine); }