stefanopagliari / bibnotes

359 stars 30 forks source link

any way to automatically generate nested subfolders? #117

Open zfhxi opened 2 years ago

zfhxi commented 2 years ago

Hello, Is there any way to automatically generate nested subfolders when import md files from JSON file? And folders' names are the names of collections/subcollections from zotero. For example, in my zotero, the nested collections is:

When I export to Obsidian, I wish bibnotes can automatically generate the corresponding directories, and the structure of directories may be like:

I generate this example by nested tags and scarcely works for me, code as:

let categories=""
const recursive_get_categories = function (_name,key_array) {
    if(key_array.length>0){
        key_array.forEach(_key=>{
            let _collection=exportedCollections[_key]
            if(_collection.items.includes(selectedID)){
                categories=_name+"/"+_collection.name;
            }
            recursive_get_categories(_name+"/"+_collection.name,_collection.collections)
        });
    }else{
        ;
    }
}
let first_level_keys=collectionKeys.filter(_key=>(!exportedCollections[_key].parent));
first_level_keys.forEach(_key=>{
    let _collection=exportedCollections[_key]
    if(_collection.items.includes(selectedID)){
        categories=_collection.name
    }
    recursive_get_categories(_collection.name,_collection.collections);
});
categories="_"+categories.replace(/\s+/g, "_")
if(!!categories){
  metadata = replaceTemplate(metadata, `{{categories}}`,categories);
}

I am not good at javascript, nodejs, so it is hard for me to implement the features "automatically generate nested subfolders". Can anyone help me?

stefanopagliari commented 2 years ago

@zfhxi would you like Bibnotes to store the related note in a folder that mirrors the structure found in Zotero?

zfhxi commented 2 years ago

@zfhxi would you like Bibnotes to store the related note in a folder that mirrors the structure found in Zotero?

Actually, I would like Bibnotes generated folders that mirrors the structure of collection folders found in Zotero. It is not simply export md files only into Export Path and I wish export md file into {Export Path}/{parent collections}/{sub collections }/xxx.md.

stefanopagliari commented 2 years ago

@zfhxi. This is an interesting idea. I have made a note of that and I will revisit once I fix some more urgent bugs.

zhechenghu commented 2 years ago

This feature seems fantastic! With the number of imported notes increasing, finding the notes I want is also becoming harder.

ybeid commented 1 year ago

Zotero allows documents to be in multiple Collections while your Obsidian Notes can only be one folder so you will need to decide which collection to pick or have duplicate files. If you use Zotfile to move files to a folder based on its collection it actually displays a selection popup when a file is in multiple collections.

It seems more appropriate to use the collections to generate nested tags then browse using a plugin such as Tag Explorer. This way the file can still be in multiple places in the hierarchy.

This would require a new placeholder {{CollectionsFullPath}} that concatenates the collection and its parents with a / as separator each and without spaces.