• Stars
    star
    272
  • Rank 151,235 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Renames pasted images and all the other attachments added to the vault

Obsidian paste image rename

📢 Starting from 1.4.0, Paste image rename becomes a general-purpose renaming plugin that can handle all attachments added to the vault.

This plugin is inspired by Zettlr, Zettlr shows a prompt that allows the user to rename the image, this is a great help if you want your images to be named and organized clearly.

Zettlr's prompt after pasting an image

image

Paste image rename plugin not only implements Zettlr's feature, but also allows you to customize how the image name would be generated, and eventually free you from the hassle by automatically renaming the image according to the rules.

Table of Contents

How to use

Basic usage

After installing the plugin, you can just paste an image to any document and the rename prompt will display:

By typing the new name and clicking "Rename" (or just press enter), the image will be renamed and the internal link will be replaced with the new name.

If you set "Image name pattern" to {{fileName}} (it's the default behavior after 1.2.0), "New name" will be generated as the name of the active file.

Set imageNameKey frontmatter

While adding a lot of images to one document, people possibly want the images to be named in the same format, that's where imageNameKey is useful.

First set a value for imageNameKey in frontmatter:

---
imageNameKey: my-blog
---

Then paste an image, you will notice that the "New name" has already been generated as "my-blog", which is exactly the value of imageNameKey:

You can change the pattern for new name generating by updating the "Image name pattern" value in settings.

For a detailed explanation and other features such as auto renaming, please refer to Settings.

Add prefix/suffix to duplicated names

The plugin will always try to add a prefix/suffix if there's a file of the same name.

Let's continue from the last section and paste the second image, the prompt will still show the new name as "my-blog", now if we just click "Rename", the file will be renamed as "my-blog-1.png", not "my-blog.png":

The -1 suffix is generated according to the default settings:

  • Because "Duplicate number at start" is false, suffix is used rather than prefix
  • "Duplicate number delimiter" - is put before the number 1

If we paste the third image without editing the "New name" input, its name will be "my-blog-2.png", the number is increased according to the largest number of "my-blog-?.png" in the attachment directory.

This feature is especially powerful if you enable "Auto rename" in settings, you can just add new images without thinking, and they will be renamed sequentially by the pattern and imageNameKey set.

Batch renaming process

New in 1.3.0

You can use the command "Batch rename embeded files in the current file" to rename images and other attachments (even notes) in the current file.

The image above demonstrates how to rename all the foo-1.png, foo-2.png… png files to bar-1-png, bar-2.png… with this feature.

You can also rename the images to the same name, and let the plugin handle the name deduplication for you. See a video demonstration here: https://i.imgur.com/6UICugX.mp4

Batch rename all images instantly

New in 1.5.0

The command "Batch rename all images instantly (in the current file)" will rename all the images in the current file according to "Image name pattern" in settings.

This is a shortcut for using Batch renaming process with certain arguments, makes everyday image renaming much easier.

Note that this command has no confirmation, please use it with caution!

Handle all attachments

New in 1.4.0

Paste image rename is not just a plugin for pasted images, it has the potential to handle all attachments that are added to the vault, no matter whether they are pasted or dragged.

To use this feature, you need to enable the "Handle all attachments" option in settings.

Additionally, you can configure the "Exclude extension pattern" to ignore files that match the given extension pattern.

FAQ

  • Q: I pasted an image but the rename prompt did not show up.

    A: This is probably because you are using the Windows system and pasting from a file (i.e. the image is copied from File Explorer, not from a browser or image viewer). In Windows, pasting from a file is like a regular file transfer, the original filename is kept rather than being created and named "Pasted image ..." by Obsidian. You need to turn on "Handle all attachments" in settings to make it work in this situation.

Settings

  • Image name pattern

    The pattern indicates how the new name should be generated.

    • Available variables:

      • {{fileName}}: name of the active file, without ".md" extension.
      • {{imageNameKey}}: this variable is read from the markdown file's frontmatter, from the same key imageNameKey.
      • {{DATE:$FORMAT}}: use $FORMAT to format the current date, $FORMAT must be a Moment.js format string, e.g. {{DATE:YYYY-MM-DD}}.
    • Examples

      Here are some examples from pattern to image names (repeat in sequence), variables: fileName = "My note", imageNameKey = "foo":

      • {{fileName}}: My note, My note-1, My note-2
      • {{imageNameKey}}: foo, foo-1, foo-2
      • {{imageNameKey}}-{{DATE:YYYYMMDD}}: foo-20220408, foo-20220408-1, foo-20220408-2
  • Duplicate number at start (or end)

    If enabled, the duplicate number will be added at the start as prefix for the image name, otherwise, it will be added at the end as suffix for the image name.

  • Duplicate number delimiter

    The delimiter to generate the number prefix/suffix for duplicated names. For example, if the value is -, the suffix will be like "-1", "-2", "-3", and the prefix will be like "1-", "2-", "3-".

  • Auto rename

    By default, the rename modal will always be shown to confirm before renaming, if this option is set, the image will be auto renamed after pasting.

  • Handle all attachments

    By default, the rename modal will always be shown to confirm before renaming, if this option is set, the image will be auto renamed after pasting.

  • Exclude extension pattern

    This option is only useful when "Handle all attachments" is enabled. Write a Regex pattern to exclude certain extensions from being handled. Only the first line will be used.

  • Disable rename notice

    Turn off this option if you don't want to see the notice when renaming images. Note that Obsidian may display a notice when a link has changed, this option cannot disable that.

More Repositories

1

httpstat

curl statistics made simple
Python
5,954
star
2

awesome-chatgpt-api

Curated list of apps and tools that not only use the new ChatGPT API, but also allow users to configure their own API keys, enabling free and on-demand usage of their own quota.
Python
5,900
star
3

sui2

a startpage for your server and / or new tab page
JavaScript
389
star
4

Share-to-ChatGPT-Shortcut

An Apple Shortcut for sharing text to ChatGPT using personalized prompts
315
star
5

jsoncv

A toolkit for building your CV with JSON and creating stylish HTML/PDF files.
JavaScript
271
star
6

cht-colors

Chinese Traditional Colors
HTML
218
star
7

ai.py

A single-file Python script that interacts with ChatGPT API in the command-line.
Python
115
star
8

python-terminal-color

Drop-in single file library for printing color in terminal
Python
71
star
9

minimal-bilibili

给你纯净的 Bilibili 视频发现体验
TypeScript
61
star
10

torext

[WORKING ON] The missing tornado mate
Python
61
star
11

xiami_exporter

Export your data from Xiami
JavaScript
59
star
12

n8n-workflows

My workflows for n8n automation
Python
44
star
13

github-toc-sidebar

Show GitHub Readme TOC as a sidebar
TypeScript
44
star
14

obsidian-telegraph-publish

Publish your Obsidian note to a Telegraph page.
TypeScript
43
star
15

obsidian-people-link

Easily create links to people within your documents.
TypeScript
38
star
16

refgen

JavaScript
34
star
17

flomo-to-obsidian

JavaScript
31
star
18

cx-extractor

Automatically exported from code.google.com/p/cx-extractor
HTML
29
star
19

autotagger

Tag .mp3 and .m4a audio files from iTunes data automatically.
Python
29
star
20

obsidian-daily-notes-opener

Easily open daily notes and periodic notes in new pane; customize periodic notes background; quick append new line to daily notes.
TypeScript
25
star
21

substance

Extract substance from the web
HTML
23
star
22

project_sketch

A nerd's boilerplate for your Python project.
Python
20
star
23

readability

html main body extractor
HTML
17
star
24

dotfiles

my rcs
Vim Script
15
star
25

deptest

dependent testing framework
Python
15
star
26

chatroom

simple chatroom using tornado long polling feature
JavaScript
14
star
27

rdl

Redis dump & load tool.
Python
12
star
28

squared

JavaScript
11
star
29

tako

A simple task manager in Django
Python
10
star
30

simplemongo

A Simple & Clear MongoDB ORM
Python
9
star
31

ts

Twitter Search CLI
Python
9
star
32

xiamifav

xiami html5 client
JavaScript
7
star
33

miniflux-on-railway

miniflux deployed on railway.app
Python
7
star
34

drawtable

Draw ASCII art box with text.
Python
7
star
35

getenv

Environment variable definition with type
Python
7
star
36

userscripts

My UserScripts
JavaScript
7
star
37

blog

HTML
6
star
38

params

A Python package that does better in request parameters validation than django.forms, wtforms, web_args or so.
Python
6
star
39

n8n-on-railway

Shell
6
star
40

eurasia

Automatically exported from code.google.com/p/eurasia
Python
5
star
41

things-to-ticktick

Export tasks from Things.app to TickTick format
Shell
5
star
42

pyconv

Text file code conversion tool
Python
4
star
43

cv

My CV site.
JavaScript
4
star
44

dbflip

flip reading for douban note
JavaScript
4
star
45

beatles

Data and tools to enjoy The Beatles better.
Python
4
star
46

feishu-exporter

Export Feishu docs with ease
JavaScript
4
star
47

rss-filter

Modify and regenerate RSS source piped in
TypeScript
4
star
48

papermodx-example

HTML
3
star
49

V2EXWitch

Chrome Extension - V2EX Account Switcher & Notifier
JavaScript
3
star
50

python-playground

Python
3
star
51

scripts

miscellaneous scripts I use
Python
3
star
52

litekv

Simple kv store for Python
Python
3
star
53

window-opener

TypeScript
3
star
54

pex_uwsgi_demo

Python
3
star
55

json_include

An extension for JSON to support file including
Python
3
star
56

fuload

Automatically exported from code.google.com/p/fuload
C++
2
star
57

gouken

Go microservice framework built on top of grpc
Go
2
star
58

django_starter_pack

My personal starter pack for Django projects
Python
2
star
59

minireact

A minimal react project boilerplate
JavaScript
2
star
60

stexplorer

Download songs from SongTaste
Python
2
star
61

learn_applescript

Notes & code pieces recorded during my exploration to AppleScript.
AppleScript
2
star
62

gopkg_opml

Python
1
star
63

qdan-archives

my archives on qdan.me
CSS
1
star
64

rime_dict

Tools for manipulating userdict of rime input method
Python
1
star
65

pinback

Pinboard backup tool
Python
1
star
66

apibox

[WORKING ON] Building blocks for HTTP API development
Python
1
star
67

learn_spider

Practicing code to learn to write a spider
Python
1
star
68

whuspec

My graduation project.
HTML
1
star
69

obsidian-chatgpt

TypeScript
1
star
70

go-to-douban

I am Xiao Meng, and I want to work in Douban, I create this repository for announcing and yelling
1
star
71

start

Shell
1
star
72

python-installer

Shell
1
star
73

printable-css

HTML
1
star
74

kindle_ebook_template

for publishing kindle ebook - specially for chinese
1
star
75

quiverweb

Web service for Quiver note app
Python
1
star
76

pinyindep

essentials for implement pinyin transforming capability in your projects with python
Python
1
star
77

gatsby-starter-netlify-cms

JavaScript
1
star
78

webpack-chrome-boilerplate

A boilerplate for building Chrome extensions with Webpack
TypeScript
1
star
79

alfred-workflows

my alfred workflows
Python
1
star
80

awesome-javascript-editors

A collection of awesome javascript editors
1
star
81

torext-admin

Python
1
star
82

html-cutter

A Chrome extension to cut out HTML fragments from a page.
JavaScript
1
star
83

aima-python

Automatically exported from code.google.com/p/aima-python
Python
1
star
84

simplate

Created with CodeSandbox
JavaScript
1
star
85

tomorrow

A new task scheduler, aimed at quick, clean, and clear
1
star
86

SMU-MScCDA-ProgrammingTest-2023

Python
1
star
87

n8n-on-fly

1
star
88

proto-typist

generate proto code from proto code
Python
1
star
89

project-nowhere

Automatically exported from code.google.com/p/project-nowhere
PHP
1
star
90

nasdaqtrader-rss

Python
1
star