{"id":13911072,"url":"https://github.com/trganda/obsidian-attachment-management","last_synced_at":"2025-07-18T10:32:19.130Z","repository":{"id":163994409,"uuid":"637269474","full_name":"trganda/obsidian-attachment-management","owner":"trganda","description":"Attachment Management of Obsidian","archived":false,"fork":false,"pushed_at":"2024-10-10T00:54:30.000Z","size":4025,"stargazers_count":188,"open_issues_count":51,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-25T20:39:27.734Z","etag":null,"topics":["attachment","custom","obsidian","obsidian-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trganda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paypal.me/trganda"]}},"created_at":"2023-05-07T03:03:12.000Z","updated_at":"2024-11-20T23:34:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"bbdb52ac-7734-4fd8-9ae7-e2ed5266357e","html_url":"https://github.com/trganda/obsidian-attachment-management","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":"obsidianmd/obsidian-sample-plugin","purl":"pkg:github/trganda/obsidian-attachment-management","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trganda%2Fobsidian-attachment-management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trganda%2Fobsidian-attachment-management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trganda%2Fobsidian-attachment-management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trganda%2Fobsidian-attachment-management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trganda","download_url":"https://codeload.github.com/trganda/obsidian-attachment-management/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trganda%2Fobsidian-attachment-management/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265742402,"owners_count":23820836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attachment","custom","obsidian","obsidian-plugin"],"created_at":"2024-08-07T00:01:56.205Z","updated_at":"2025-07-18T10:32:18.539Z","avatar_url":"https://github.com/trganda.png","language":"TypeScript","funding_links":["https://paypal.me/trganda"],"categories":["TypeScript"],"sub_categories":[],"readme":"# Obsidian Attachment Management\n\nThis plugin supports more flexibly setting your attachment location with variables like `${notepath}`, `${notename}`, `${date}` and `${md5}`. An override setting feature can be used to change the global setting of a folder, file or extension.\n\n\u003e Read the [Original Name](#original-name) section before using the `${originalname}` variable.\n\n## Installation\n\n- Install from Obsidian community plugins.\n- Clone this repo\n  - `npm i` to install dependencies\n  - `npm run build` to start compilation in watch mode.\n  - Copy the `main.js`, `manifest.json` and `style.css` files to your vault `VaultFolder.obsidian/plugins/obsidian-attachment-management`\n- Download the release file and unarchive the file to your vault `VaultFolder.obsidian/plugins/obsidian-attachment-management`\n\n## Usage\n\nInstall and enable the plugin, after configuration you can paste or drop attachment file as usually and it will be auto renamed.\n\nThis plugin supports a command `Rearrange linked attachments/Rearrange all linked attachments`. If you run this command, it will rename all attachments (image file default, to rename another type, you need to enable [Handle All Attachements](#handle-all-attachments)) that have been linked in the `markdown` or `canvas` file as you configured.\n\n![SCR-20230511-rrtk](./images/SCR-20230511-rrtk.png)\n\n**Notice**: The `Rearrange linked attachments/Rearrange all linked attachments` is currently an experimental feature; if you want to try it out, it's best to back up your files first.\n\n### Overriding Setting\n\nYou can set the attachment path setting for a file or folder. The priority of these settings are:\n\n```\nfile setting \u003e most close parent folder setting \u003e global setting\n```\n\nIf you want to reset the settings of files or folders to the global setting, use the command `Reset Override Setting` or the `Reset` button on the override setting panel. **The reset will only work on each file or folder that you trigger the command on**. A more appropriate method to handle resetting will be added in the future.\n\n### Original Name\n\nThe `${originalname}` represents the original filename (without extension) of the attachment you added to the vault. Some people want to keep the original filename and/or combine it with other variables like `${date}`. If you want to keep the original filename of an attachment, set the **Attachment Format** with `${originalname}`.\n\nIf you want to use `${originalname}` with other variables, like `${originalname}-${date}`. This plugin will persist the original name for future use. Suppose you change the **Attachment Format** from `${originalname}-${date}` to `IMG-${originalname}`, it's work fine.\n\nThe original name is stored in **data.json**, the configuration file of the plugin. You can find it at `.obsidian/plugins/attachment-management/data.json`.\n\n```json\n  \"originalNameStorage\": [\n    {\n      \"n\": \"Pasted image 20240113222517\",\n      \"md5\": \"9B1546EBA299E1A2A2FC86C664A15073\"\n    }\n  ],\n```\n\nAs you can see, the original name was saved with a hash, so if you add the same file multiple times, only the last one will be saved. The **originalNameStorage** will not clear automatically, use command `Clear unused original name storage`. This command will keep the entry if the hash of an attachment is matched.\n\n## Roadmap of Features\n\nThis plugin currently supports:\n\n- [x] Setting the attachment location with `${notepath}`, `${notename}`, `${date}` and `${parent}`\n- [x] Auto-rename the attachment when pasting to `markdown` or `canvas`\n- [x] Auto-rename the attachment file or folder while you rename the article (`markdown` or `canvas`) file\n- [x] Auto-rename the attachment when dropping to `markdown` or `canvas`\n- [x] Re-Arrange the attachment file that is linked by `markdown` or `canvas` to the corresponding path as you configured (experimental)\n- [x] Processing duplicate attachment\n  - [x] Processing duplicate attachment on create (the first time, you paste or drop an attachment in notes)\n  - [x] Processing duplicate attachment on rename\n- [x] Override attachment configuration for specified notes or folder\n- [x] Exclude folders that you want this plugin to skip\n  - [x] Add Exclude folder by menu\n\n## Settings\n\nThe path of attachment is composed of three parts :\n\n```\n{root path}/{attachment path}/{attachment name}.extension\n```\n\nAnd you can use the variables below to config:\n\n- `${notepath}`: The **directory** of the `markdown` or `canvas` file under the vault root.\n- `${notename}`: The **filename** of the `markdown` or `canvas` file (without file extension).\n- `${parent}`: The **parent** folder name of the `markdown` or `canvas` file.\n- `${originalname}`: The **filename** of the attachment file when it was first created in Obsidian.\n- `${date}`: Date time format by [Moment format options](https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/01-format)\n\n\u003e **Notice** before using `${originalname}`, there is something you should know. This plugin will **not persist** the original name, it only use the filename to generate the attachment name on create event (first time added to obsidian). This means if you have used `${originalname}`, when you rearrange the attachment, there is no new name generated for the attachment, it just used the current name (i.e. change `Attachment format` from `asset-${originalname}` to `asset-1-${originalname}`, and use rearrange command, it's useless).\n\n### Root Path to Save New Attachments\n\nYou **must** select a root folder to save the attachment associated with a `markdown` or `canvas` file.\n\n![SCR-20230511-rgge](./images/SCR-20230511-rgge.png)\n\nIt can be set using the config of Obsidian in `Files \u0026 Links` and reset using this option.\n\n- Copy Obsidian settings: use the Obsidian setting in the `Files \u0026 Links` section.\n- In the folder specified below: set a fixed folder.\n- Next to note in folder specified below: in the subfolder of the current `markdown` or `canvas` file.\n\n### Attachment Path\n\nA sub-folder to place attachment under the `{root path}`, available variables:\n\n- `${notepath}`: The **directory** of the `markdown` or `canvas` file under the vault root.\n- `${notename}`: The **filename** of the `markdown` or `canvas` file (without file extension).\n- `${parent}`: The **parent** folder name of the `markdown` or `canvas` file.\n\nDefault value `${notepath}/${notename}`.\n\n### Attachment Format\n\nSet how to rename the attachment and available variables:\n\n- `${notename}`: The **filename** of the `markdown` or `canvas` file (without file extension).\n- `${originalname}`: The **filename** of the attachment file when first time it created.\n- `${date}`: Date time format by [Moment format options](https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/01-format)\n- `${md5}`: MD5 hash of the attachment file (calculated when the attachment file was first created in the vault).\n\ndefault value `IMG-{date}`.\n\n### Date Format\n\nUse [Moment format options](https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/01-format) to set the `${date}`, default value `YYYYMMDDHHmmssSSS`. You should always use the `${date}` variable to prevent the same file name.\n\n#### Exclude Extension Pattern\n\nThis option is useful if you want to ignore some file types. Write a Regex pattern to exclude certain extensions from being handled.\n\n![SCR-20230918-pkys](./images/SCR-20230918-pkys.png)\n\n### Automatically Rename Attachment\n\nAutomatically rename the attachment folder/filename when you rename the folder/filename where the corresponding md/canvas file is placed.\n\n### Extension Override Setting\n\nThis feature allows you to specify the setting for a serials extension. You can use a regex pattern here to override the global setting.\n\n![SCR-20230918-pihr](images/SCR-20230918-pihr.png)\n\n### Exclude Paths\n\nIf you want some paths to be skipped by this plugin, add them to the text area.\nIf you have multiple paths, split them with a semicolon ';'.\n\nBy default, the \"Exclude paths\" will only work on the folder you added, and that folder contains at least one markdown file; you can toggle \"Exclude subpaths\" to exclude subpaths also.\n\n\u003e **The path is case-sensitive and should not have a leading slash '/' at the beginning.**\n\n### Known Issues\n\n- ~~No support for processing duplicated file names right now (in development). In backup, you could use the data variable [`x`](https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/01-format/) to use Unix timestamp with millisecond as filename (it will prevent duplicated filename).~~\n- When pasting or dropping a file in `canvas` and `markdown`, it will delay showing the updated link/filename. The reason is that Obsidian's API has no `paste` or `drop` event support for `canvas`, so I have implemented it in another way, and this caused the delay in renaming the attachment.\n\n![Screen Recording](./images/canvas_drop_delay.gif)\n\n- Suppose you have a structure below with default configuration:\n  - Attachment directory, \"assets/notes/hello/1.png\"\n  - Note directory, \"notes/Hello.md\"\n  - Running the `Rearrange` command may lead to an error since the folder already exists but has a lowercase name.\n\n## FAQ\n\nQ: What if I add '/' to Exclude Paths?\n\nA: It will exclude the whole vault folder.\n\nQ: Is this plugin support auto rename pdf file?\n\nA: By default, this plugin will only rename the image file. For other file types, you can use the extension override setting.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrganda%2Fobsidian-attachment-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrganda%2Fobsidian-attachment-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrganda%2Fobsidian-attachment-management/lists"}