From 602e611152f6272f7ad8cc35c9f53226ab531d95 Mon Sep 17 00:00:00 2001 From: Matthew Turk Date: Mon, 12 Jun 2023 15:17:34 -0500 Subject: [PATCH] Add specifying parent folder for binary files --- src/Generator.ts | 7 +++++++ src/Setting.ts | 14 ++++++++++++++ src/main.ts | 2 ++ 3 files changed, 23 insertions(+) diff --git a/src/Generator.ts b/src/Generator.ts index cf97a77..e7614f6 100644 --- a/src/Generator.ts +++ b/src/Generator.ts @@ -34,6 +34,13 @@ export class MetaDataGenerator { if (!(file instanceof TFile)) { return false; } + if ( + !file.path.startsWith( + normalizePath(this.plugin.settings.binaryFilePath) + ) + ) { + return false; + } const matchedExtension = this.plugin.fileExtensionManager.getExtensionMatchedBest(file.name); diff --git a/src/Setting.ts b/src/Setting.ts index 545b096..31c7de8 100644 --- a/src/Setting.ts +++ b/src/Setting.ts @@ -118,6 +118,20 @@ export class BinaryFileManagerSettingTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName('Binary file parent folder') + .setDesc('Only this folder will be watched for new files') + .addSearch((component) => { + new FolderSuggest(this.app, component.inputEl); + component + .setPlaceholder('Example: folder1/folder2') + .setValue(this.plugin.settings.binaryFilePath) + .onChange((newFolder) => { + this.plugin.settings.binaryFilePath = newFolder; + this.plugin.saveSettings(); + }); + }); + let extensionToBeAdded: string; new Setting(containerEl) .setName('Extension to be watched') diff --git a/src/main.ts b/src/main.ts index 523eb7c..f67dfef 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,7 @@ interface BinaryFileManagerSettings { autoDetection: boolean; extensions: string[]; folder: string; + binaryFilePath: string; filenameFormat: string; templatePath: string; useTemplater: boolean; @@ -36,6 +37,7 @@ const DEFAULT_SETTINGS: BinaryFileManagerSettings = { 'pdf', ], folder: '/', + binaryFilePath: '/', filenameFormat: 'INFO_{{NAME}}_{{EXTENSION:UP}}', templatePath: '', useTemplater: false,