JYC333 / obsidian-attachment-name-formatting

Obsidian plugin that automatically rename attachment files' name
MIT License
45 stars 5 forks source link

Obsidian Attachment Name Formatting

This plugin will format all attachments in the format: "noteName attachmentFormat indexNumber.xxx"

The attachmentFormat are image, audio, video and pdf. IndexNumber is ascending number from 1 based on the attchmentFormat.You can change the default format for different type of attachments and the connector in the setting. Basically, there are three components can be enabled or disabled in attachment name: noteName, time (format time), and pathHash (absolute note path hash). Therefore, there could be seven types for the attachment name format:

  1. noteName attachmentFormat indexNumber.xxx
  2. noteName attachmentFormat indexNumber time.xxx
  3. noteName attachmentFormat indexNumber pathHash.xxx
  4. noteName attachmentFormat indexNumber time pathHash.xxx
  5. attachmentFormat indexNumber time.xxx
  6. attachmentFormat indexNumber pathHash.xxx
  7. attachmentFormat indexNumber time pathHash.xxx

The space in between can be set by your choice, even use nothing in between.

There is a one-in-many situation, which means using the same attachment in many different notes. In this plugin, it gives three options to handle this situation:

  1. Default: Always rename with the note name;
  2. Copy: Create a copy for the attachment and rename with the new note name;
  3. NoChange: Stick to the first time that attachment is renamed, and will not occupy index number

When using "Copy" mode, it will take a bit longer time than usual renaming time, around 1-2s. For "NoChange" mode, if you want to rename the attachment after it's renamed by this plugin, you need to rename it by yourself in the valut or in the file system right now. May add a Command later to handle this.

Note: The base path of the attachments is based on the Valut setting: Files & Linsk -> Attachment folder path.

Features

Core Function

Other Function

Supported attachment format

  1. Image files: png, webp, jpg, jpeg, gif, bmp, svg
  2. Audio files: mp3, wav, m4a, ogg, 3gp, flac
  3. Video files: mp4, webp, ogv, mov, mkv
  4. PDF files: pdf

webm file type will be regard as vedieo even if it can be audio.

Known Issues

Roadmap

Development Setup

  1. Setup change log tool
npm install -g commitizen
npm install -g conventional-changelog-cli
  1. Update change log
git add .
git cz
  1. Update version
npm run version --new=<new_version>
  1. Push tag
git push origin --tag

Thanks

I develop this plugin as a hobby, spending my free time doing this. If you find it valuable, then please say THANK YOU or buy me a coffee...

ko-fi

LICENSE

MIT