Saving file formats

I'm new to Directory Opus, and I have searched this forum for an answer, as well as watched the video " Resizing File Display Columns, and Folder Formats." I can't seem to figure out how to make it do what I want.

Generally, I have a file hierarchy (folder structure) with several folder/subfolder levels. Files exist mostly in the lowest (deepest?) level of the hierarchy, and I want those folders sorted by date modified. However, all other folders I want sorted alphabetically by file or folder name.

I have set up 2 favorite folder formats, and the "soft by filename" is set as my global default. When I open a folder that should be sorted by date modified, I manually set the folder format as such. But, when I go up through the folder tree, several (but not all) folders have been re-sorted by date modified. When I change any one of them to sort by filename, and go back to the lowest level (which I want sorted by date modified), it has been changed to sort by filename.

For some folders, I have specifically gone into the File Options and SAVED the folder format. I think this works...as long as I don't turn on the LOCK icon at the bottom - then everything gets changed to whatever format is currently showing. I have hundreds of folders with files in them that I want sorted by date modified, and hundreds of folders in the folder tree that I want sorted by filename. Do I have to open EVERY single one and save the folder format???

1 Like

Try

image

image

image

then something like
image

would do all folders with 'Movies' in the name at first level

and

image

would do all sub-folders

if you wanted deeper levels then keep adding \\* if using regular expressions or \* otherwise.

Can your requirements be written like this?

  • Sort all files and folders by name
  • Exception for folders that only contain files: sort these by modified

How deep is the folder structure?

Are all the deepest folders on the same level?

It might be easier to use a script to change the formats than to set up a folder format.


Nay, that sounds like a recipe for a mental breakdown. Let's find something smarter :wink:

Yes, I think that would work.

There are varying levels depending on the client. Everything starts from:

D:\Sync\ClientData\

Under that I have 4 main categories:
Business
Personal
Caseware
T1 output

Under most of these, the next level is the client name, and under that can be anywhere from 0 to 4 sub-levels. The "T1 output" folder has no subfolders.

In Windows Explorer (or File Manager or whatever they're calling it now), I had the same global "Folder Options" set up (sort by filename), and then when I viewed a "lowest level" folder for the first time, I clicked the column header "Modified". After that, Windows remembered my selection for each of those folders. But, Directory Opus doesn't seem to "remember" the same way - it always resets.

My only issue with Windows Explorer is that it seems to fight for access to the files and folders shared under Sync (Sync is similar to OneDrive, Sharepoint, Google Drive, etc), causing a 5-10 second lag every time I want to open or rename a file. That's why I converted to Directory Opus - it doesn't seem to have as much conflict with Sync. I am hoping I can find a solution to the folder sorting issue. Otherwise, I may have to ditch Sync and try Sharepoint instead.

Opus 13 remembers the same way, unless Automatic Formats has been turned off or an explicit format has been created for the path which overrides the automatically remembered one.

But doing it via automatic formats, you’d still need to set up each folder individually, instead of some rules for all folders. Setting up a few wildcard rules would be better, and also mean fewer things to edit if you want to change how all those folders look later on.

I can't think of a good any way to solve this with a path format, but a script can handle this rather easily.

function OnInit(initData) {
    initData.name = 'SortByNameOrModified';
    initData.version = '2024-01-30';
    initData.url = 'https://resource.dopus.com/t/saving-file-formats/48421';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAfterFolderChange(afterFolderChangeData) {
    if (!afterFolderChangeData.result) return;

    var tab = afterFolderChangeData.tab;
    if (String(tab.path).indexOf('D:\\Sync\\ClientData\\') < 0) return;

    var hasSubFolder = false;
    var folderEnum = DOpus.FSUtil().ReadDir(tab.path);
    while (!folderEnum.complete && !hasSubFolder) {
        var folderItem = folderEnum.Next();
        hasSubFolder = folderItem.is_dir;
    }

    var cmd = DOpus.Create().Command();
    cmd.SetSourceTab(tab);
    cmd.RunCommand('Set SORTBY=' + (hasSubFolder ? 'name' : 'modified'));
}

Save EventSortByNameOrModified.js.txt to   

%appdata%\GPSoftware\Directory Opus\Script AddIns

How to use buttons and scripts from this forum

Set SORTBY

Ok, good to know - I've just upgraded to Opus 13

Thanks! I'll have to look at that thread re: how to use scripts in Opus. Don't have time now. But, I do like using scripts in various apps (even still use some old DOS batch files), so I appreciate this immensely @lxp !