Greepp
August 4, 2022, 1:13pm
#1
Use case or problem
I think it’s will be vary useful if I can manipulate multiple files in search pane.
It can:
Move selected files to folder in search pane. Thus, It’s possible to move files with tag or specific pattern.
Assign tags to selected files in search pane
Proposed solution
Just like file explorer.
Alt
: Select a file
Shift
: Select files between two file
Ctrl-A
: Select all files
Or “Select all files” can be default mode instead of Ctrl-A
.
Greepp
August 14, 2022, 12:23pm
#2
I find some ways to make this indirectly. You can add a macro in quickadd plugin to implement feature that move files in search pane. The code is here.
module.exports = async function moveFilesInSearch(params) {
const {app, quickAddApi: {suggester, yesNoPrompt, checkboxPrompt}} = params;
const searchView = app.workspace.getLeavesOfType('search')[0]?.view
if(searchView === undefined) {
new Notice('The core search plugin is not enabled');
return;
}
const searchResults = searchView.dom.getFiles();
if(!searchResults.length) {
new Notice('No search results available');
return;
}
const filePaths = searchResults.map(f => f.path);
const selectedFiles = await checkboxPrompt(filePaths, filePaths);
if(selectedFiles === undefined || !selectedFiles.length){
new Notice('No selected files');
return;
}
const folders = app.vault.getAllLoadedFiles().filter(f => f.children).map(f => f.path);
const targetFolder = await suggester(folders, folders);
if (!targetFolder) return;
for (const file of selectedFiles) {
const tfile = app.vault.getAbstractFileByPath(file);
await app.fileManager.renameFile(tfile, `${targetFolder}/${tfile.name}`);
}
}