trganda / obsidian-attachment-management

Attachment Management of Obsidian
MIT License
144 stars 8 forks source link

[FR] Different settings for different folder #1

Closed Mara-Li closed 1 year ago

Mara-Li commented 1 year ago

It will be cool if we could add the option to add "override folder". For example, if an attachment is send in a specific folder, the processing will be different.

Use case :

For the moment, I need to rename/move the image each time, and it's pretty unconvenient.

I also need to keep my _assets folder for attachment I don't need to move

trganda commented 1 year ago

Tks for your suggestion 😃

Look like you want a special option (no globaly) to set the attachment path of a note or notes under a folder, right? That's a good idea to manage attachment more flexiblely.

I will try to develop this feature in next version.

Mara-Li commented 1 year ago

Thanks! <3

trganda commented 1 year ago

I have open a pull request for this feature, you can try this feature right now, question and advice are welcome

If you have no building enviroment, you can download this pre-build plugin

Mara-Li commented 1 year ago

Tried but :

 22:41:39.672 Override Settings, 20. REFERENCES/22. Personnages/Ashling May/Illustration.md: [object Object]
plugin:attachment-management:286 22:41:51.081 On Create Event - File: _assets/download20190702230706.png
plugin:attachment-management:286 22:41:51.081 Active File Path 20. REFERENCES/22. Personnages/Ashling May/Illustration.md
plugin:attachment-management:286 22:41:51.081 New Path of File: _assets/20. REFERENCES/22. Personnages/Ashling May/IMG-2023-05-15.png
plugin:attachment-management:286 22:41:51.173 Source Path of Rename: _assets/download20190702230706.png
plugin:attachment-management:286 22:41:51.173 Destination Path of Rename: _assets/20. REFERENCES/22. Personnages/Ashling May/IMG-2023-05-15.png
plugin:attachment-management:286 22:41:51.173 replace text ![[download20190702230706.png]] ![[download20190702230706.png]]
plugin:obsidian-icon-folder:2378 element with data path not found _assets/Illustration-15-05-2023.png
plugin:attachment-management:286 22:41:51.187 On Rename Event - New Path and Old Path: _assets/Illustration-15-05-2023.png _assets/download20190702230706.png
plugin:attachment-management:286 22:41:51.187 RenameType: RENAME_EVENT_TYPE_FILE
plugin:attachment-management:286 22:41:51.187 Old Note Path: _assets
plugin:attachment-management:286 22:41:51.187 Old Note Name: download20190702230706
plugin:attachment-management:286 22:41:51.187 Old Attachment Path: _assets/_assets
plugin:attachment-management:286 22:41:51.187 New Attachment Path: _assets/_assets
app.js:1 Sync Error!
app.js:1 Error: ENOENT: no such file or directory, open 'K:\Constellation\_assets\download20190702230706.png'
plugin:attachment-management:286 22:41:51.202 Attachment path does not exist: _assets/_assets
app.js:1 Uncaught (in promise) Error: Destination file already exists!
    at e.<anonymous> (app.js:1:601991)
    at app.js:1:236930
    at Object.next (app.js:1:237035)
    at a (app.js:1:235753)
plugin:customizable-menu:224 Épingler
plugin:customizable-menu:224 Copier l'url Obsidian
plugin:customizable-menu:224 Lint file
plugin:customizable-menu:224 Ouvrir les rétroliens
plugin:customizable-menu:224 Ouvrir les liens sortants
plugin:attachment-management:286 22:42:32.095 
{attachmentRoot: 'Illustration', saveAttE: 'nextToNote', attachmentPath: '${notename}', attachFormat: '${notename}-${date}', type: 'FILE'}
attachFormat
: 
"${notename}-${date}"
attachmentPath
: 
"${notename}"
attachmentRoot
: 
"Illustration"
saveAttE
: 
"nextToNote"
type
: 
"FILE"
[[Prototype]]
: 
Object
Mara-Li commented 1 year ago

It seems that the plugin crash the renaming if the destination path (folder) already exists. Also, the console log seems wrong with overriding.

Note : In my test My file have the same name of the folder, so the only difference in their filepath is the extension So I try to use : Root folder : 20. REFERENCES/22. Personnages/Ashling May/Illustration Attachment path : ${notename} (ie : Illustration here) Attachment format : ${notename}-${date}

The plugin seems to check with using the path without the filename, so it brokes in my settings (folder note)

I tried a lot of settings/option and can't get the settings I want :(

It seems it doesn't take the overriding settings…

trganda commented 1 year ago

Yes, this plugin has no increment number for duplicate files right now (as you mentioned in [BUG] Image name are not incremented) In my original plan, it will be implement after the override setting, but I have ignored some use cases and lead this problem.

And after review my code, I have found more problem. I will fix these bugs as soon as possible. :)

trganda commented 1 year ago

I rewrited some code and make the override setting work. For the duplicate files problem will processing in a new pull request.

For the override setting, I have tried to test some use case:

I hope this can make this feature working as expected.

attachment-management.zip

Mara-Li commented 1 year ago

I will try it ! Thanks :D

Mara-Li commented 1 year ago

THANKS! Works as expected now.

As I know a little in the dev of Obsidian Plugin, I made some update (notably checkCallback for commands). I will made a PR in your Prod branch!

trganda commented 1 year ago

Happy to hear that! And PR are welcome, I'wll merge this PR first.