Select and manipulate multiple flies in search pane like file explorer

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.

4 Likes

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}`);
    }
}

fire (3)

2 Likes

Given the massive benefit of the newest properties feature. I believe this feature ought to be revisited and added.

I have discussed a similar topic in the discord server. Here’s what I said:

I had a question regarding if it is possible to select multiple files within the search component ? My goal is to be able to use properties to determine the “type” of the file, based on what type it is I want to manually move these to a folder.

I was happy to know that we are able to select all matching properties but it seems I am unable to shift+click multiple files from here in order to move them, I also tried control+click with no luck. Both of which work within the files component but do not work within the search.

With the following image displaying how I want to select all files that are “movies” and be able to select them all and move them to a specific directory.

3 Likes