[Tiny Plugin Request] - Fast moving of Files

i would like to know the cost of this:

Was told by a good coder to first look for a right click menu code and i found one.
However i do not know how to write this plugin idea myself.

i was wondering if someone would be interested in tweaking the right click part of this code from: GitHub - mgmeyers/obsidian-copy-block-link: Get links to blocks and headings from Obsidian's right click menu.

i noticed i have to many scattered files around my vault.
currently with the single folder window, its a very tedious task with many deep folders to move files. to their correct folder. right click move to… is not efficient enough IMO.

So to reduce the clicks and time spend i had this plugin idea.

Using the right mouse menu from the code above.
It would be so usefull if in the dropdown instead of just “find file location” …
There is also the button. “move file to…” And “move file to current note location…”

Reason why: You cannot move files or notes by right clicking them inside of obsidians note. Having deep directories far apart form each other is a nightmare when having only 1 folder window to make use of.

icons that could be used would be:
Lucide | Lucide Lucide | Lucide


Just a faster solution,
If you want to move files, you could try out the plugin auto note mover

You can also use the “Move file to another folder” command, which you can assign to a hotkey - in my case Ctrl + M.

Then on any note press Ctrl+M and start typing a folder name. Very fast, and much faster than right-clicking.

I am trying to move files from within the note itself.
You can right click and find the file. but this takes time with my very large vault.
Then i have to find the next folder etc.

I use CTRL+M too for moving to another folder. This is not what i am trying to do though.
Thanks for the suggestion.

I am trying to right click move file to another folder on the link itself in the note.

Thats where the problem lies.
Because this file is not in the same folder as the current note i am viewing is.

So i am trying to bring them together fast.

Thats why the plugin request.

My vault is so big. that loading the file explorer and finding files actually takes time.

Interesting plugin, thanks for the suggestion.
However i do not think this will solve my problem fast enough.
If i am reading correctly i would need to tag all my notes.
And its more about me moving .pdf files or images towards my note.

I copy paste a lot from the internet. And it throws all the stuff in one folder.
I did enable the part where now it pastes it if its a note already in a folder.
But sometimes that note is also not in the correct folder because i tend to quickly create notes instead of folders first.

Why can i not edit or delete my original post?

Short updated version:
Obsidian Note has ![[whereisthis.pdf]] file link in it
I want to be able to right click the [[name of file]] get a dropdown menu and do.
“Move file to this current notes folder.”

You can do this with a quick Templater template :slight_smile: (with a hotkey rather than a right-click)

  1. Add the below template and assign it to a hotkey.
  2. Put your cursor into a link as per the screenshot.
  3. Press the hotkey. It will move the linked file into the same folder as the currently open note.


const editor = app.workspace.activeEditor
// Get the link at the current cursor position
const link = editor.editor.getClickableTokenAt(editor.editor.getCursor())
if (link?.type === 'internal-link') {
  // Get the current folder
  const currentFolder = editor.file.parent.path
  // Get the linked TFile
  const linkedFile = app.metadataCache.getFirstLinkpathDest(link.text, '')
  // Move the linked file to the current folder
  await app.fileManager.renameFile(linkedFile, currentFolder + '/' + linkedFile.name)
  new Notice(linkedFile.basename + ' has been moved to ' + currentFolder)

wow i have to try this out! brilliant if it works!
Did you write this yourself?

Yes, I wrote it just now, can confirm it works.

I should say it doesn’t need to be Templater, it could be CustomJS or QuickAdd or whatever hotkey plugin you’re using.

oh my god. this is genius!
Thank you so much. been trying to get this function for so long now.
This is speeding things up by 1000x. Brilliant work and smart usage of templater. :+1:


Hopefully this has use for you or someone else using obsidian :smiley:
For me its GREAT!! :tada:

1 Like

Damn why didn’t I think of this? I could have used this years ago to move my attachments from my default folder I named “inbox”

Here’s my tweaked version because I like to keep my attachments in a subdir called _aux:

// 2023-10-05 Set hotkey to ⇧⌥M in Templater settings.

// Source: https://forum.obsidian.md/t/tiny-plugin-request-fast-moving-of-files/68710/8

// Set this if you want to keep your attachments in a sub-directory
const ATTACHMENT_SUBDIR = '_aux';

const editor = app.workspace.activeEditor;

// Get the link at the current cursor position
const link = editor.editor.getClickableTokenAt(editor.editor.getCursor());
if (link?.type === 'internal-link') {
  // Get the target folder
  let targetFolder = editor.file.parent.path;
  // Get the linked TFile
  const linkedFile = app.metadataCache.getFirstLinkpathDest(link.text, '');
  // Change target folder to subdir if necessary
  const ext = linkedFile.name.toLowerCase().split('.').pop();
  if (typeof ATTACHMENT_SUBDIR  !== 'undefined' && ATTACHMENT_SUBDIR !== '' && !['md', 'canvas'].includes(ext)) {
      targetFolder += '/' + ATTACHMENT_SUBDIR;
  // Check current folder
  const currentFolder = linkedFile.parent.path;
  if (targetFolder !== currentFolder) {
      // Create target folder if necessary
      try {
          await app.vault.createFolder(targetFolder);
      } catch (e) {
      // Move the linked file to the current folder
      await app.fileManager.renameFile(linkedFile, targetFolder + '/' + linkedFile.name);
      new Notice('`' + linkedFile.name + '` was moved to `' + targetFolder + '`');

Now I need another template that processes all the attachments in the current note and moves them all. Do you know which API function lets me iterate through all the links?

I think this existing plugin might do what you want:

Attachment management

As someone already mentioned here, the best solution is to use the Templater quick template using a hotkey. Simply add a template, then assign it to a hotkey, hover the cursor over the screen and press the hotkey. This will instantly move all linked files to the same folder as the currently open note.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.