Need move existing attachment files that are now along side notes into dedicated subfolders (in attachments folder) named like the note name?

I have imported notes from Evernote. Most notes are imported this way, example used here:

Evernote folder was “Legal”.

Evernote note name was “Contracts”. The note contains 1 attachment called in this case “Agreement123”.

Now in Obsidian:

The way things were imported in Obsidian TYPICALLY (but not always):

In vault there is a folder “Legal”.

Inside there is a folder .attachments.

The Obsidian note “Contracts” is now saved in the “Legal” folder.

The attachment “Agreement123” is saved inside .attachments folder in a subfolder there called “Contracts”. Its path is: Vault > Legal > .attachments > Contracts…

And I am perfectly happy with this. This is how I want it.

The issue is as I mentioned, in some cases, the attachments were not placed into the .attachments folder when certain notes was imported. I don’t understand why it happens (I re-run it multiple times to test) but it seems Evernote notes containing 1 attachment only, or notes that contains only attachment were typically imported in this alternative way:

The obsidian note “Contracts” is saved in the “Legal” folder.

The attachment “Agreement123” is saved directly in the “Legal” folder along with the note.

About 2/3 of my notes were saved correctly (the way I want) and about 1/3 imported the the other way.

So obviously it’s not pretty now because I have some attachments in .attachments folder in their respective subfolders there, while many attachments are lurking around alongside with the notes in the main folder.

Is there a way to clean it up?

I would like to move those notes to were they should be (where xxxxx is the name of the note).

Vault > Legal > .attachments > xxxxxxxx… > …

Maybe some sort of script to deal with it?

I already tried copy and move notes, merge notes etc… to see if the attachments get cleaned up, but no, the attachment remains where it was saved initially.

This is resolved.

The plugin Consistent Attachments and Links can do that… GitHub - dy-sh/obsidian-consistent-attachments-and-links: Obsidian plugin. Move note with attachments.

The key is to configure the field ATTACHMENT SUBFOLDER that needs to be configured:

_resources${filename}

Also, the other plugin called Attachment Name Formatting will rename all these attachments so that their name matches the Note name plus a suffix.

This plugin didn’t need any configuration.

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