SebastianMC / obsidian-custom-sort

Take full control over the order and sorting of folders and notes in File Explorer in Obsidian
GNU General Public License v3.0
255 stars 19 forks source link

Select folders & files separately #46

Closed tomoayan closed 1 year ago

tomoayan commented 1 year ago

EDIT: Want to select and sort folder and files differently. e.g. < a-z (Folders), > a-z (Files) ^ Super Simplified Example.

SebastianMC commented 1 year ago

Hi @tomoayan

the relevant fragment of sorting specification would be:

 /folders
  < a-z
 /:files
  > a-z

It groups all folders and sorts them alphabetically and then, below folders, groups all files and sorts them in reversed alphabetical order.

In order to work, the above snippet has to be put in the sorting-spec: key in YAML frontmatter of relevant note. The simplest case would be the sortspec note anywhere in the vault with additional explicit specification of target folder to sort, for clarity.

The full example to put in sortspec note would be then:

---
sorting-spec: |
 target-folder: /
 /folders
  < a-z
 /:files
  > a-z
---

in result it would apply the sorting order to the root folder of the vault (and only, no subfolders affected).

REMARK: indentation matters, and in this specific example, the order specifications < a-z and > a-z are nested by one more space relatively to the preceding lines /folders and /:files. It tells the sorting engine to apply the sorting rules to the preceding group of items. Otherwise (no nesting) the order would be applied to all items in the folder. And if two not-nested order specifications would occur, a syntax error would be raised telling about duplicate sort order specification for the target folder.

Please let me know if you want to exercise variants of the above sorting specification, e.g.: to sort some other folder(s), not the root folder only.

tomoayan commented 1 year ago

It groups all folders and sorts them alphabetically and then, below folders, groups all files and sorts them in reversed alphabetical order.

Thanks 👍