jyc333 / obsidian-attachment-name-formatting Goto Github PK
View Code? Open in Web Editor NEWObsidian plugin that automatically rename attachment files' name
License: MIT License
Obsidian plugin that automatically rename attachment files' name
License: MIT License
In the new version of Obsidian 1.5.12, this plugin can't rename any attachments at all. Hope this bug can be amended, thank you!
I suggest three related features here.
Add a feature to allow user to rename the attachments for all the notes within a folder and all subfolders.
Another feature to rename the attachments within vault.
Log
Also important to save a log that contain any attachments that cannot rename successfully such as the known bugs. When it is finish renaming all the notes, it will automatically show the log how many attachments can't be rename unsuccessful and the link to the note and attachment.
The log layout might look something this.
Note Title 1 (Bold)
Note Title 2 (Bold)
Because renamed the attachment won't update file modify time, when I inserted attachment and formated name second time and synchronize file,the issue will occur on synchronized terminal.And then the synchronized terminal will distroy online data.Like this:
synchronized terminal will distroy online data:
Old_Attachment_Name | Old_Modify_Time | Old_Attachment_ID | problem | New_Attachment_Name | New_Modify_Time | New_Attachment_ID |
---|---|---|---|---|---|---|
attachment1 | 1:00 | 1 | attachment1 | 1:00 | 1 | |
attachment2 | 2:00 | 2 | attachment2 | 7:00 | 7(inserted) | |
attachment3 | 3:00 | 3 | wrong to replace→ | attachment3 | 2:00 | 2 |
attachment4 | 4:00 | 4 | wrong to replace→ | attachment4 | 3:00 | 3 |
attachment5 | 5:00 | 5 | wrong to replace→ | attachment5 | 4:00 | 4 |
attachment6 | 6:00 | 6 | wrong to replace→ | attachment6 | 5:00 | 5 |
attachment7 | 6:00 | 6 |
online data is wrong:
Attachment_Name | Modify_Time | Attachment_ID | problem |
---|---|---|---|
attachment1 | 1:00 | 1 | none |
attachment2 | 7:00 | 7(inserted) | none |
attachment3 | 3:00 | 3 | ID must be 2 |
attachment4 | 4:00 | 4 | ID must be 3 |
attachment5 | 5:00 | 5 | ID must be 4 |
attachment6 | 6:00 | 6 | ID must be 5 |
attachment7 | 6:00 | 6 | ID must be 6 |
So I suggest adding a parameter to distinguish between files with the same name——add "renamed time" in formatting name like : "filename_attachmentFormat_indexNumber_renamed time.xxx"。Example:
Old_Attachment_Name | Old_Modify_Time | Old_Attachment_ID | New_Attachment_Name | New_Modify_Time | New_Attachment_ID | |
---|---|---|---|---|---|---|
attachment1_20230422230012 | 1:00 | 1 | attachment1_20230422230512 | 1:00 | 1 | |
attachment2_20230422230013 | 2:00 | 2 | attachment2_20230422230513 | 7:00 | 7(inserted) | |
attachment3_20230422230014 | 3:00 | 3 | won't replace→ | attachment3_20230422230514 | 2:00 | 2 |
attachment4_20230422230015 | 4:00 | 4 | won't replace→ | attachment4_20230422230515 | 3:00 | 3 |
attachment5_20230422230016 | 5:00 | 5 | won't replace→ | attachment5_20230422230516 | 4:00 | 4 |
attachment6_20230422230017 | 6:00 | 6 | won't replace→ | attachment6_20230422230517 | 5:00 | 5 |
attachment7_20230423230518 | 6:00 | 6 |
This feature also can improve experience of "Automatic formatting" feature.
Can you add a setting to allow the plugin to be triggered manually, instead of automatically?
If you use an image in more than one note, it renames the image each time you open up each note even though the image does not and probably should not be renamed.
Hi!
Thanks for making this plugin and maintaining it. I find it very useful!
I found a possible bug.
How to reproduce:
This triggers an error for me: Error: Destination file already exists!
My current workaround:
Add modify time after index
Rescan attachments in current file
Add modify time after index
Rescan attachments in current file
againHi! Love this plugin :) Thanks for working on this. I have an issue where sometimes when I insert an attachment the plugin does not pick up on it. I'm not seeing any issues in the console. Would it be possible to make a command that checks all the attachments in the note and renames them if still needed?
When Adding pdf files to a document I would like to option to retain the name of the pdf rather than renaming them. This would allow for easier management of notes with multiple pdf files embedded.
Could this be set either in option or through YAML?
spaces in file name is not a good choice, please change the file name to
filename_attachmentFormat_indexNumber.xxx
thank you
As a user, I would like to organize my attachments by file type, so that I can easily find them later by file type.
I installed this plugin, hoping that I would be able to name my images "images/2348980.png", video files "videos/2342345.wav", etc. like I have done with periodic notes. This way there would be subfolders in the Attachments folder.
I have Obsidian settings under "Files & Links" -> Default location for new attachments -> In subfolder under current folder.
When editing a file, invoke plugin command "Attachment Name Formatting: Rescan Attachments in Current File" from Obsidian Command Palette menu. The renamed attachments are relocated to "assets" folder under Vault root, instead of "assets" folder under the current folder.
Expected behaviour: the renamed attachments should move to location following the Obsidian settings under "Files & Links" -> Default location for new attachments".
It cannot change the name of an image linked to a *.excalidraw file
Can you please confirm this?
like the title says. files are renamed to "fileName image #" and then after a few hours I find the file has everything replaced with "tmp_FileName image #" breaking all the links.
Hello, i'm looking for ways that help make plugins more secure. One way is through Reproducible Builds, which could detect a plugin version with a malicious main.js
file that wasn't actually built from the source code.
A package-lock.json
or yarn.lock
is needed though to build a main.js
from source that's identical to the one obsidian downloads when installing the plugin. In general, any way you could make the build process easy to reproduce would help, like by removing steps that only work on your local development environment.
Could this plugin add support to mobile devices?
It seems that it doesn't work on mobile devices now.
Hi
This looks like a useful plugin, but presently it's only useful for the odd image
I would, really, appreciate it if the following categories could be introduced:
.doc, .docm, .docx , .docx , .dot, .dotm, .dotx, .odt, .rtf, .txt, .wps, .xps, xls, xlsx, xlsm, xltm, xlsb, xltx, ods, .numbers, .xl, .pages, .tex, .mpp, csv, ppt, pptx, pdf, dwg, dxf, xlthtml, .xlsmhtml, .xlshtml, .pptmhtml, .ppthtml, .dothtml, .docmhtml, .dochtml
.eml, .msg
.log, .cap, .pcap
.vsdx, .vsd, .adp, .sdr, .cvx, .graffle, .notebook, .vdx, .cddz, .vss, .igs, .rtd, .opx, .vst, .ink, .mmap, .flo, .nmind, .brd, .dm2, .vsx, .vtx, .itm, .flo, .rise, .mgcb, .xmmap, .mp, .dia, .xmi, .vpp, .wdp, .igx, .edg, .ygf, .xmind, .gdraw, .czd, .vstx, .vssx, .vstm, .vssm, .pn, .sx, .edx, .edxz, .bpm, .bpmc, .pu, .plantuml, .simp, .cdml, .spl7, .de, .eddx, .nvp, .adf, .gxt, .anb, .cvxcad, .monopic, .monosnippet, .nsa, .bpmn, .mag, .jpd, .sda, .xlgc, .xbk, .ddt, .nbk, .spk, .mmat, .cdt, .tpl, .umlclass, .abc, .af3, .gtemplate, .mgtx, .cdsx, .scl, .far, .flw, .gliffy, .architect, .mmas, .drawio, .ccd, .cir, .ndb, .ndx, .ndtx, .nlx, .nlb, .esd, .fhc, .mmx, .art, .vpd, .mdeck, .xmdeck, .arh, .af2, .imd, .gpj, .mmms, .xmmas
.7z, .cbr, .deb, .gz, .pak, .pkg, .rar, .rpm, .tar.gz, .xapk, .zip, .zipx
.htmlz, .zhtml, .xht, .dhtml, .htx, .hhk, .chm, .oth, .mhtml, .hhc, .mht
.appxbundle, .lgo, .in, .unity, .awk, .kv, .rbxl, .cs, .sb, .sb2, .ypr, .kt, .ipr, .appx, .ino, .sb3, .rbxm, .class, .pyd, .py, .cpp, .luc, .c, .gitattributes, .hs, .gs, .arsc, .vbp, .slogo, .ph, .mm, .tt, .am4, .xq, .has, .gch, .vcproj, .sc, .aidl, .lua, .md, .b, .xap, .pas, .asm, .cc, .pbg, .resx, .trx, .po, .resources, .java, .patch, .gm81, .swc, .config, .vdproj, .mf, .dex, .csproj, .res, .ocx, .res, .ise, .gmx, .gmk, .swift, .ymp, .smali, .hpp, .fs, .pwn, .qpr, .v12.suo, .def, .cod, .r, .sln, .yml, .appxupload, .cd, .y, .bbc, .fbp, .bet, .capx, .rb, .nk, .bluej, .pjx, .suo, .rul, .swd, .so, .aia, .xsd, .dtd, .mpx, .bpl, .ane, .xcdatamodeld, .nuspec, .entitlements, .lisp, .wdgt, .pbxbtree, .ssi, .xamlx, .ccs, .ctp, .dgml, .pyw, .agi, .s, .ml, .au3, .mk, .xt, .dox, .proto, .targets, .pb, .ipr, .pl, .s19, .ex, .vcxproj, .d, .vb, .o, .pbj, .hbs, .rpy, .fxml, .v, .h, .tk, .w32, .idb, .myapp, .as3proj, .rexx, .w, .l, .scc, .ap_, .fpm, .twig, .apa, .asc, .4db, .cxp, .yaml, .xaml, .ads, .sc, .msix, .asi, .gsproj, .jspf, .gm6, .ftl, .pbxuser, .csx, .ipch, .ui, .testsettings, .jsfl, .bas, .tlh, .rdlc, .tpu, .csp, .fxc, .dcp, .f, .abc, .mo, .pas, .nupkg, .mrt, .cbp, .livecode, .i, .as, .am7, .f90, .cp, .cls, .mak, .sud, .framework, .vbx, .hh, .pbxproj, .storyboard, .kdevprj, .xcworkspace, .idl, .dmd, .kdevelop, .plc, .gld, .iml, .vm, .svn-base, .cu, .v, .diff, .inc, .markdown, .vhd, .gitignore, .m, .wiq, .as2proj, .pika, .jic, .autoplay, .hal, .vbg, .sma, .alb, .rsrc, .ism, .dpr, .nib, .asm, .bdsproj, .prg, .pbk, .tur, .fsscript, .am6, .iconset, .pro, .ist, .wdp, .wdw, .wdl, .for, .ltb, .bsc, .mcp, .nvv, .lsproj, .sltng, .haml, .oca, .lds, .lnt, .df1, .wsc, .xpp, .dproj, .erl, .dsgm, .clw, .rbc, .m, .bb, .sas, .wsp, .nsi, .ilk, .dpl, .dbml, .cxx, .pri, .nbc, .octest, .omo, .xcconfig, .pl1, .pkgdef, .m4, .gem, .nls, .sup, .kpl, .playground, .vbproj, .uml, .pl, .mss, .owl, .xoml, .xojo_xml_project, .ctxt, .inl, .mshc, .msha, .sym, .v11.suo, .erb, .cdf, .hxx, .pcp, .mer, .pyx, .jpr, .cp, .pxd, .csi, .src, .a2w, .exp, .forth, .ccn, .dgsl, .pli, .rss, .vdp, .nw, .pm, .vsmacros, .edmx, .dm1, .wxl, .xojo_project, .t, .mv, .nsh, .asvf, .resw, .wxs, .ppc, .lbi, .dob, .ftn, .ptl, .mom, .cbl, .dec, .hpf, .vssscc, .psc, .acd, .caf, .ss, .a, .pot, .gszip, .wixout, .rnc, .iwb, .p3d, .gemspec, .rbp, .bs2, .wixobj, .wpw, .lbs, .wixlib, .dpkw, .wixmst, .src.rpm, .xcodeproj, .vspx, .jcp, .rav, .vbz, .fxl, .xcsnapshots, .xojo_binary_project, .wdgtproj, .scriptterminology, .pdm, .odl, .tcl, .pkgundef, .xojo_menu, .tld, .gorm, .eql, .xql, .rodl, .xcappdata, .mdzip, .tmlanguage, .textfactory, .bbproject, .cvsrc, .vdm, .lxsproj, .clips, .xqm, .ned, .fbz7, .vsps, .addin, .refresh, .rise, .ged, .fxcproj, .testrunconfig, .resjson, .mshi, .bcp, .am5, .lucidsnippet, .gs3, .ccp, .cob, .iws, .tli, .vspscc, .ple, .dbproj, .pri, .vsz, .vtm, .gmo, .fsproj, .gameproj, .licx, .rex, .dcuil, .tns, .vc, .pch, .ent, .spec, .c, .brx, .xcarchive, .lproj, .idt, .dba, .licenses, .greenfoot, .ctl, .4th, .fsproj, .dsp, .xib, .edml, .vgc, .p, .tds, .mod, .bbprojectd, .csn, .vtv, .aps, .r, .dpk, .msp, .mpr, .fxpl, .bpg, .groupproj, .inform, .vsmdi, .sdef, .vsmproj, .rbw, .sqlproj, .prg, .fsx, .vtml, .gfar, .dbo, .tu, .dcproj, .psm1, .pde, .lhs, .cfc, .wixproj, .pod, .vsp, .dcu, .rkt, .exw, .dfm, .csi, .msl, .ncb, .vcp, .dba, .fsi, .xquery, .sbproj, .nqc, .magik, .groovy, .wixmsp, .lit, .wixpdb, .scriptsuite, .ssc, .wxi, .dbpro, .artproj, .ccgame, .jpx, .deviceids, .gmd, .r
Extensions you do not cater for go into an Other "bucket"
Thanks
PS: The first 2 categories are most important (Documents and e-mail)
Thanks for making this plugin!
I found an issue where the plugin crashes when the setting 'Default location for new attachments' is set to 'Vault folder'. I've set a breakpoint on the line I've linked below and attachmentFolderPath
is undefined in this case, causing an error when trying to call startsWith
on it.
I have a LOT of image attachments in my vault, and the attachments/img/
folder that this plugin sends them all to has 919 files as of this writing. Having that many makes trying to find a particular file in either Obsidian's or the OS's file explorer rather unwieldy.
I propose that a feature be added (can be optional if you wish) that makes the plugin automatically create a subfolder within the subfolder created by the "Subfolders for attachments" setting, named after the note that the attachment belongs to, and save all attachments into that sub-subfolder.
For example, if I'm working in a note (foo.md
) and paste several images into the note, the plugin would rename the files as normal (e.g. foo_image_1.png
), create a folder called foo
within attachments/img/
, and move all the attachments for foo.md
(of the file type that belongs to that subfolder, in this case images) into attachments/img/foo/
.
In the case of my vault, rather than scrolling through 919 images to find the right one, I would instead only need to scroll through 112 folders to find the attachments for the note that I'm looking for. Much more manageable!
Thank you for making such a great plugin! :)
The attachment renaming feature seems to only work for wiki links, using eg [[filename]] and such Wiki links.
Standard Markdown hyperlink syntax is used by default, such as ()[] is invalid
In addition, the ability to export attachments that are not linked in the library is also limited
If there is a vault in the vault, all attachments in the inner vault will be exported
Hi, when I first installed this plugin in July, all open notes were automatically renamed with the filename of the attachment. After a recent update to 1.4.4, it was found that the function of automatically updating filenames is no longer available. What's the situation now?
When I paste in new images, the rename process will sometimes lose images(i.e., the image gets tmp renamed and then fully renamed, but the link in the note still points to the tmp file). Other times, Obsidian live preview will display the wrong image and the read view will display the correct image. I can even link to the same image next to each other and it will display two different images.
[feature request]
Add "move all files from current note" option
This would allow to easily gather all note related files/attachments and move them to another vault or quickly share them.
Optionally allow for autodeletion after export/move.
export all unused files
Allow export of all attachments which are not used in any notes.
This would help tremendously with cleanup.
Thank you for this great plugin.
Hi!
First of all: thanks for your work, I appreciate the effort you put into this plugin: managing attachments is both important and a mess, and honestly this plugin seems to be my favourite one to manage attachments.
After installing it, everything works as intended. However, as you can imagine, I've already made hundred of attachments and I want to "normalize" them
There's the option "Scan files in folder" but it acts weird:
I found that when I insert an image in the header, all the file names below are changed once.
But it may cause the files to be lost.
I observed that the file name was changed to tmp...
first. My guess is that closing the file or sync upload at this point may leave the tmp...
name there, thus causing the note can't be found in the temp file name.
Is it possible to pass another naming strategy, such as using time as the name and increasing the suffix when the name is duplicated?
因为阅读模式下没有重命名功能,如果能在新标签页打开图片,然后进行重命名以及其他操作(比如我会看图片的反链面板,看看有什么笔记都引用了这个图片)会方便一些,在ob内部进行操作,也能更新链接
For example:
A.md uses "A Image 1.jpg" yesterday,
B.md uses "A Image 1.jpg" today, the plugin will changed this image to "B Image 1.jpg". The image name in A.md will be changed accordingly.
Is there any better solution for this situation?
Rescan Attachments in Current File,It is not working properly,nothing happened,The attachment has not been renamed
When I go back to 2.1.5, everything is running smoothly
My notes follow a rule:
index.md
in the folder.I have these rules since they make it navigate in a file explorer (reduces list size by half). And also for publishing the notes as a website.
The current plugin format does not consider the route of the file (i.e. folder1/folder2/folder3).
It only considers the fileName
(attachmentType
remains the same, and indexNumber
may also be duplicated easily, so let's ignore them).
Due to my rule 2, all attachments in index.md
files will be named the same - index-image-indexNumber.xxx
.
I know that the problem is specific to my situation, and I think it's fine if the whole route is not in the attachment name (which would also solve the problem - but would make file names too big).
A simpler solution would be to have a unique identifier (by some logic - maybe hash the route) at the end of the filename.
Storing "time" as the unique string doesn't help, since I also do linting (which edits multiple files quickly - at almost the same time).
https://developers.google.com/speed/webp
some website use webp format to increase pages' speed
Between the file name and attachment name, we can set a connector, while there is no need to force the same connector between attachment name and the number. So I suggest we can seperate these two connectors and set them by ourselves.
As the image shows, the connector in the picture force the same connector between attachment name and number. I suggest we can set two options : one is connector between the file name and attachment name, another is connector between attachment name and the number.
By the way , I hope the connector can be set none, which means I don't need any connector there. Thank you!
Hi,
Can you add a setting to allow the user to specify what character to use to replace an empty space in a filename? With v1.4.3, it uses the default underscore character to replace empty space. Thanks.
Currently, there is no reference list or document that list the variables that we can use to specify the format. I also google search and here in Github and can't find it. Can you add a reference list in the settings of what variables you can use? Thanks.
I use very often notes with pasted screenshots.
Today I was reviewing older daily notes and I realized that in older notes (created before I started to use your plugin), some pictures are now missing. There is only info - pasted image was not created yet - click to create it.
Why I think it is connected with your plugin, is that it started about 2 weeks ago and there was no other change in my Obsidian. And - what is strange - the 1st image in this note was renamed and has new name. The 2nd is gone and has old name.
There is no other plugin working with files in attachment folder, only yours.
It looks like when I open the note, plugin starts to rename images - few are successfuly renamed - and others are maybe deleted, maybe renamed... I can not find these missing pictures in attachment folder with even with new/old names. They are gone.
Love the extension so far, I wish there was a way however to exclude certain file types from being renamed. I am mainly thinking about svg for example. I create a lot of diagrams using draw.io, which I consider less as part of a note, and more like stand-alone data (which I often refer to in multiple notes). Would it be possible to add file type exclusion for this plugin?
Thank you for your work either way!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.