You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constfolderOrFile=this.app.vault.getAbstractFileByPath("folderOrFile");if(folderOrFileinstanceofTFile){console.log("It's a file!");// add to TFile[]}elseif(folderOrFileinstanceofTFolder){console.log("It's a folder!");// do recurrsion}
Example from GPT
constisTemplate=(filePath: string)=>{// check if filePath is a valid template
...
};// Create a utility function for recursive searchconstdetectTemplatesInFolder=async(folderPath: string)=>{constfiles=awaitthis.app.vault.getFiles();lettemplateFiles=[];for(leti=0;i<files.length;i++){constfile=files[i];if(!file.path.startsWith(folderPath)){// ignore unrelated files/folders continue;}if(fileinstanceofTFile&&isTemplate(file.path)){// found a template filetemplateFiles.push(file);}elseif(fileinstanceofTFolder){// found a sub-folder, do recursionconstsubfolderTemplates=awaitdetectTemplatesInFolder(file.path);if(subfolderTemplates.length>0){templateFiles.push(...subfolderTemplates);}}}returntemplateFiles;};
The text was updated successfully, but these errors were encountered:
At this function
chatgpt-md/main.ts
Lines 919 to 933 in 1cd9234
It could recurrsively call it self according to folder or file.
https://marcus.se.net/obsidian-plugin-docs/vault#is-it-a-file-or-folder
Example from GPT
The text was updated successfully, but these errors were encountered: