11import LinkConverterPlugin from 'main' ;
2- import { App , TFile , Notice , normalizePath } from 'obsidian' ;
2+ import { App , TFile , Notice , normalizePath , TFolder } from 'obsidian' ;
3+ import { getFilesUnderPath } from './utils' ;
34
45/* -------------------- LINK DETECTOR -------------------- */
56
@@ -126,16 +127,16 @@ export const convertLinksInActiveFile = async (plugin: LinkConverterPlugin, fina
126127 }
127128} ;
128129
129- // --> Command Function: Converts All Links in All Files in Vault and Save in Corresponding Files
130- export const convertLinksInVault = async ( plugin : LinkConverterPlugin , finalFormat : 'markdown' | 'wiki' ) => {
131- let mdFiles : TFile [ ] = plugin . app . vault . getMarkdownFiles ( ) ;
132- let notice = new Notice ( 'Starting link conversion in your vault ' , 0 ) ;
130+ // --> Convert Links under Files under a Certain Folder
131+ export const convertLinksUnderFolder = async ( folder : TFolder , plugin : LinkConverterPlugin , finalFormat : 'markdown' | 'wiki' ) => {
132+ let mdFiles : TFile [ ] = getFilesUnderPath ( folder . path , plugin ) ;
133+ let notice = new Notice ( 'Starting link conversion' , 0 ) ;
133134 try {
134135 let totalCount = mdFiles . length ;
135136 let counter = 0 ;
136137 for ( let mdFile of mdFiles ) {
137138 counter ++ ;
138- notice . setMessage ( `Converting the links in your vault ${ counter } /${ totalCount } .` ) ;
139+ notice . setMessage ( `Converting the links in notes ${ counter } /${ totalCount } .` ) ;
139140 // --> Skip Excalidraw and Kanban Files
140141 if ( hasFrontmatter ( plugin . app , mdFile . path , 'excalidraw-plugin' ) || hasFrontmatter ( plugin . app , mdFile . path , 'kanban-plugin' ) ) {
141142 continue ;
@@ -149,6 +150,11 @@ export const convertLinksInVault = async (plugin: LinkConverterPlugin, finalForm
149150 }
150151} ;
151152
153+ // --> Command Function: Converts All Links in All Files in Vault and Save in Corresponding Files
154+ export const convertLinksInVault = async ( plugin : LinkConverterPlugin , finalFormat : 'markdown' | 'wiki' ) => {
155+ convertLinksUnderFolder ( plugin . app . vault . getRoot ( ) , plugin , finalFormat ) ;
156+ } ;
157+
152158const hasFrontmatter = ( app : App , filePath : string , keyToCheck : string ) => {
153159 let metaCache = app . metadataCache . getCache ( filePath ) ;
154160 return metaCache . frontmatter && metaCache . frontmatter [ keyToCheck ] ;
0 commit comments