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
260 stars 19 forks source link

How to apply settings to all folders and files except root folder? #10

Closed ocreturner closed 1 year ago

ocreturner commented 1 year ago

hello I finally achieved what I wanted ! im using

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

but I don't want my root files to be affected by the sorting. how do I have the root files ignored but not the children folders and the content in them

SebastianMC commented 1 year ago

Hi!

the short answer is: specify the sorting rule for the root folder explicitly

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

 target-folder: /
 sorting: standard
---

Explanation: specifying the target folder by name has always a higher priority than any wildard-pattern-based sorting specification.

In your specific example, the line target-folder: //* sets the sorting rules for all folders (including root) of the vault. Then, adding a line target-folder: / sets the sorting rules for the root / folder specifically, overriding the pattern-based configuration.

I've used the sorting: standard in the example - in result, the files and notes in the root folder will be managed by the standard obsidian sorting mechanism (the Change sort order toolbar button in File Explorer). You can obviously specify any other sorting rule supported by the plugin instead.

BTW you can use the simpler syntax target-folder: /* instead of target-folder: //*. They are equivalent.