alberti42 / obsidian-import-attachments-plus

Import attachments by moving them into the vault.
MIT License
14 stars 0 forks source link

Feature request: Create local copy of linked file #7

Open Sebert81 opened 1 month ago

Sebert81 commented 1 month ago

Hi, I am a teacher and use Obsidian to manage my documents, classes and such. There is a feature I am sorely missing and maybe you can help me and implement it in your plugin.
My vault atm is basically divided into two sections:

When I start a new topic with a class I need to copy the worksheets from the master section to their folder and rename them, for example 01_basic_economics.docx has to be renamed to 2024_2025_ClassA_basic_economics.docx. This is very tiresome. My idea/request: Create a local copy of a linked file.

  1. Example: Within the canvas of ClassA I link to "01_basic_economics.docx" located in the master section.
  2. Right click => Create local copy => The plugin creates a copy of the file and moves it to the location of your note, depending on your settings. In my case to the subfolder of the location of the canvas.
  3. Optional, but not that important: Add naming schemes like "20242025%p_%f" where %p would be the title of the parent folder and %f the original filename.

I hope that I could convey my idea. Thanks!

alberti42 commented 1 month ago

Hi, I understand that your workflow could massively benefit from automation. However, it seems something much tailored to your needs. I think we can support something like this idea, but I need to understand it in much more basic terms. Can you abstract from your example?

If you now drag&drop files from the same vault, the plugin asks you whether you want to make a copy or only a link. It does not allow you to move files that are already in the vault — if I remember it correctly. This was by design.

So, what you want to have is being able to automatically rename the file after importing it? I can imagine that automatic renaming may be something useful for other people as well.. but we need to understand what kind of pattern to offer to the user. It should not make the plugin difficult to be used.

Sebert81 commented 1 month ago

Hi,

If you now drag&drop files from the same vault, the plugin asks you whether you want to make a copy or only a link. It does not allow you to move files that are already in the vault — if I remember it correctly. This was by design.

when I drag & drop a file from the left hand navigation panel into my note I do not get asked whether the file should be moved or copied, that only happens when I drag &drop a file from the system explorer. Plus: Drag & Drop is not what I have in mind because I have a lot of attachments in a lot of subdirectories in my vault , and they usually aren't visible in my navigation (done via css snippet) to keep things tidy. But finding those attachments when creating a link in a note is quite easy because I know their naming scheme.

Hi, I understand that your workflow could massively benefit from automation. However, it seems something much tailored to your needs. I think we can support something like this idea, but I need to understand it in much more basic terms. Can you abstract from your example?

Abstract, (hope this helps):

Now: If you have attachments in your vault in folder A and want to have/use individual copies of these attachments in another folder B in your vault, you have to make copies of that attachment in folder A and move the copies manually to folder B.

Desired: If an attachment from folder A in the same vault is linked in a note in another folder B, make it possible to simply create a copy of that attachment in folder B and replace the link with a link to that new copy in folder B.

So, what you want to have is being able to automatically rename the file after importing it? I can imagine that automatic renaming may be something useful for other people as well.. but we need to understand what kind of pattern to offer to the user. It should not make the plugin difficult to be used.

Actually the automatic renaming is not that important to me, though it would be nice.

alberti42 commented 1 month ago

when I drag & drop a file from the left hand navigation panel into my note I do not get asked whether the file should be moved or copied, that only happens when I drag &drop a file from the system explorer.

I checked and you are right. You are not shown any prompt and the plugin directly creates a link. This is by design. I am wondering if we should rather show a dialog. My original idea is that if you already have your file in the vault, it does not mke much sense that you create a second copy. Also, moving the file is dangerous because you make break links.

Of course it is possible for the plugin to first check whether the file is linked, and then if the file is moved, update all links.

I think it makes sense to implement this feature in the future, namely asking the user whether to copy or move a file that was already in the vault. If the file is moved and it was linked, all links will be updated automatically. I know it is not your direct problem. However, what do you think?

Desired: If an attachment from folder A in the same vault is linked in a note in another folder B, make it possible to simply create a copy of that attachment in folder B and replace the link with a link to that new copy in folder B.

I see. I am not sure why you want to make a duplicate of a file that is already in your folder. Is it because the original works like a template and you want to be able to specialize/edit the file in the folder B?

Do you want to convert all links in a note with copies of the linked files? Or only selected links which you can select by right clicking on them? But probably this only makes sense when you import attachment in a subfolder. I am not sure what the behavior should be for users that import attachments to a common shared folder.

I think that both options can well be done. But I am not sure there are many people using them. This could be a separate plugin, or maybe the same plugin and having this as an advanced option.

Sebert81 commented 1 month ago

I see. I am not sure why you want to make a duplicate of a file that is already in your folder. Is it because the original works like a template and you want to be able to specialize/edit the file in the folder B?

Yes, as I mentioned in my first post I use Obsidian as a tool to manage the worksheets for my students. The original is my template, and I create individual copies for each class that uses them. The sheets/files contain lesson materials, tasks and excercises. I open them in front of the class, fill in my or the student's solutions. So they are my individual notes for each class.

Do you want to convert all links in a note with copies of the linked files? Or only selected links which you can select by right clicking on them? But probably this only makes sense when you import attachment in a subfolder. I am not sure what the behavior should be for users that import attachments to a common shared folder.

Only a selected link. If I would use a common shared folder the behaviour should be the same, because I still would want to create a copy of a file without searching the file itsself in the navigation panel and give it a new name. Though I agree that in my usecase it makes much more sense to use subfolders.

Just shows me how versatile Obsidian and its users are. I never thought that people don't create copies of attachments.

alberti42 commented 1 month ago

Just shows me how versatile Obsidian and its users are. I never thought that people don't create copies of attachments.

Well, for templates, I always used Templater plugin. I use a lot of templates myself. Are you sure that this plugin does not already cover your needs? I am hesitant to provide something that overlaps with Templater, which I think it works great.

Probably what you need is an extension to Templater that allows you to add to the current note attachments that are themselves MarkDown notes created with Templater?

If I would use a common shared folder the behaviour should be the same, because I still would want to create a copy of a file without searching the file itsself in the navigation panel and give it a new name.

Makes sense.

But to me, it is very involved the whole idea that the user first create a link to an other internal note and then right-click on it to convert it to a real copy. I want to help you and found the best solution for you, but that is so streamlined that is useful for everybody.

Sebert81 commented 1 month ago

Just to make sure: I am talking about attachments (pdf, docx, odt ..) not markup notes.

I'll look into templater later, but at first glance I dont see how this applies to my case.