I have a mess of a folder on our company's network drive. I've been unofficially put in charge of it, mostly because I'm the one that actively updates most of it. Much of it was not organized at all. I want to archive folders based on when they were last updated but some folders have a modified date that is much newer than the last modified file contained inside it.
I'm not scripty enough to do this quickly. Can someone make a script that looks at the files and folders underneath the selected folder and changes the selected folder's Modified date to match the newest modified date inside that folder?
Optionally allow it to be recursive, which means you'd have to go to the deepest nested folder and fix its modified date first so it could be reflected in the upper-level folders.
I did find this tool. If there's no script by the time I'm ready to tackle the cleanup, I'll download it and give it a spin. But I'd love it if this was available inside DOpus.
Nir Sofer's foldertimeupdate is an excellent tool. I trigger it using a front end script which builds a customised config file primed to execute against whatever folder is in the current tab.
it has locked the same directory for which it is trying to SetAttr.
Yes. Strange error. Doesn't appear when ReadDir() is used recursively. Explicitly closing the FolderEnum object with folderEnum.Close() seems to help. Please try
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
var fsu = DOpus.FSUtil();
cmd.deselect = false;
DOpus.ClearOutput();
DOpus.Output('Enumerating...\n');
for (var e = new Enumerator(tab.selected_dirs); !e.atEnd(); e.moveNext()) {
var item = e.item();
var lastMod = 0;
var folderEnum = fsu.ReadDir(item);
// var folderEnum = fsu.ReadDir(item, 'r'); // recursive
while (!folderEnum.complete) {
var folderItem = folderEnum.Next();
if (folderItem.is_dir) continue;
if (folderItem.modify > lastMod) lastMod = folderItem.modify;
}
folderEnum.Close();
if (lastMod > 0) {
var cmdLine = ('SetAttr FILE="' + item + '" META "lastmodifieddate:' + lastMod.Format('D#yyyy-MM-dd T#HH:mm:ss') + '"');
DOpus.Output(cmdLine);
cmd.RunCommand(cmdLine);
}
}
DOpus.Output('\n... done.');
}