Use the current note name in the attachment subfolder name

Use case or problem

The feature of specifying a subfolder for attachments (requested here) has been implemented in 0.10.8.

A common request in the comments of the aforementioned feature request was to be able to specifically use the note name in the attachment folder name, be it to make a structure like :
Attachments/<note_name>/attach1.png
or my personal favorite, inherited from Typora :
Current note folder/<note_name>.assets/attach1.png
which is a clear, elegant way of keeping attachments close to the note and separated from attachments from other notes that could be in the same folder.

For my use-case, this enables easy export and compatibility with other software and users of a shared knowledge base folder, keeping a nice filetree.

Proposed solution

Add a variable (Typora uses ${filename}) representing the current note name to be used in the subfolder name.
If the note name changes, it could be nice to automatically change the subfolder name but that could be left to the user.

Related feature requests (optional)

81 Likes

I use Obsidian on my laptop and Noteplan 3 for iPad to edit on the go.
However, the action for saving attachments of Obsidian and Noteplan 3 is slightly different.

Noteplan situation

When adding hoge.png to Notes/aaa.md,
Noteplan puts hoge.png to Notes/aaa_attachments/hoge.png.

Obsidian situation

When adding hoge.png to Notes/aaa.md,
Obsidian puts hoge.png to Notes/attachments/hoge.png.

Proposed solution

Thanks to the recent update, Obsidian now has an option to save attachments to the folder where I write.
So I would like the Obsidian team to create an additional option to allow Noteplan users to attach an image seamlessly.

Also would be great to set same folder structure as for notes.
For example if we have 2 notes:
./note1.md and ./folder/note2.md
For attachments would be
./attachments/note1/attach.png for first note
and ./attachments/folder/note2/attach.png for second.

2 Likes

I think it would be a excellent idea if there would be a variable like {{filename}} that we could inject in the file name for the option in subfolder under current folder. Then users could define the name how their preferred other editor works.

4 Likes

It would be amazing if Obsidian could mirror Typora’s behavior, where attachments are copied to a note-specific folder based on a user-defined pattern (e.g. ./_resources/${note_name}/{attachment_name}).

That’d make a world of difference for me.

7 Likes

I like and need this function very much. Is this function available now? :smiley:

1 Like

Unfortunately, still waiting for this feature.

2 Likes

Yes +1
The more I think about “Image management” the more I think it’s urgent and important to do something quickly about it.

Why? Well, you don’t want to create hundreds of notes with attached images and have to migrate your own notes because at last, a new feature is coming :upside_down_face:

And I now think it’s a Must-Have.

9 Likes

Don’t forget to “like” my original post at the top to bring attention to this feature request :slight_smile:

ZIM-like attachment browser
.
A while ago I used Zim-Wiki App and liked their approach to attachments. In my opinion, this was one of their best features and I would like to see it in Obsidian. It works like this:
.
After creating a note and dragging a file (or an image) into it to create a link in the note, the attachment folder is created with the same name as the note and in the same folder.

(Say, you create a note “TEST” in folder X. The note file will have a path “…/X/TEST.md” and its attachment folder will have a path “…/X/TEST”).
.
So far, nothing special. But what matters is the following:

  1. Moving & renaming. If you rename or move the note, the attachment folder is automatically renamed (moved) as well. That is, the attachment folder always follows its note, and they always remain interconnected and in the same folder.

  2. Attachment browser. You can see all your files (images) related to the note in a separate sidebar pane — called “Attachment Browser” in a similar way you can see “Backlinks”, “Outline”, “Tags”. From there, you can open individual files or you can open the attachment folder in your System Explorer. This is very handy for example, when you need to send all documents related to the topic to someone else.

  3. Attachment Folders/Files hidden in the “File Explorer”. The attachment folders and individual files are not shown in the “File Explorer” (I mean in your vault´s tree). This is great because they don’t clutter your tree and the tree is greatly reduced and simplified. You have all your files related to the topic nicely organized and can see them in the attachment browser, when necessary.

This is a great way of organization for my purposes. I´m a lawyer. When I have a note about some legal issue, I can just dump all related sources (court decisions, articles, etc) into its attachment folder and always find them there. And in my tree (left-side pane) I have only the name of the topic and not a bunch of notes, files and other clutter; the tree always remains simple and uncluttered.

13 Likes

I, also, was a fan of Zim’s clever and elegant way of handling the file system !

There is a plugin that aims to offer the same functionality : xpgo/obsidian-folder-note-plugin: Plugin to add description note to a folder for Obsidian. (here on the forum : Folder Note Plugin: Add description note to folder)

It’s not quite there yet, in particular you have to click to ask for a specific note to turn into a folder note, it’s not as seamless as Zim.

1 Like

What exactly should happen when notes are renamed? The related {notename}.assets folder should also be renamed?

1 Like

Yes it should ! :slight_smile:

3 Likes

I really like this idea. My notes, which I use for my trainings and presentations, have many images. So, not only form my file handling this would be a great solution.

5 Likes

So much want this :slight_smile:

+1

Using {{filename}} variable would be great, but {{date}} would also be very useful.

2 Likes

thanks for bring this up. this is a minor feature but can provide a huge experience improvement.
personally, i put a lot related markdown files in one folder. current setting only allows me to use the same subdirectory for all markdown files, which is unconvinent to manage or edit the images. put filename in the path variable will be great help.
+1 !!

Upvote on allowing a filename variable in the folder path! It would make the organization of files/attachments so much better!

1 Like

@popebabylon @fmzz @edo @Martin @luckman212 @Slavomir @Ellanxis @Tchak
I developed a plugin which allow users to modify attachment folder path and pasted image name with variables(i.e ${filename}, ${date}).

Don’t forget to STAR me if you like it :grinning_face_with_smiling_eyes:.

RainCat1998/obsidian-custom-attachment-location-plugin

The plugin only work with obsidian newer than v0.12.17. (Current stable version is v0.12.15, insider v.0.12.19). It’s possible to support older version (just hook cm.__handler.paste) but the solution is not that stable.

11 Likes

Nice, thank you.
Can you provide some info how to use?
I installed it, set ${filename} or .\${filename} or $filename or .\$filename folder name in plugin settings, drag&drop photo and it was added to “same folder as current file” like in “File & Links” settings.