Customize attachment location with tokens (${fileName}, ${date:format}, etc) like typora.
- Modify location for attachment folder.
- Modify filename for Pasted Files.
- Same to "Files & Links -> Default location for new attachments".
- Put "./" at the beginning of the path if you want to use relative path.
- See available tokens.
- example:
assets/${filename}
,./assets/${filename}
,./assets/${filename}/${date:YYYY}
- See available tokens.
- example:
${originalCopiedFilename}-${date:YYYYMMDDHHmmssSSS}
,${filename}-img-${date:YYYYMMDD}
- Obsidian default:
Pasted image ${date:YYYYMMDDHHmmss}
. - Note: This setting only changes image filename from clipboard. If your attachment is copied from the explorer, obsidian will just copy the original file to the attachment folder without renaming.
Automatically update attachment folder name if "Location for New Attachments" contains ${filename}
.
- Automatically update attachment files in target md file if "Pasted Image Name" contains
${filename}
. - Just simply substitute
${filename}
string in attachment filename. So it may be dangerous if multiple files share the same prefix.
Automatically replace whitespace in attachment folder and file name with hyphens.
Automatically set all characters in folder name and pasted image name to be lowercase.
Paste images from clipboard converting them to JPEG.
The smaller the quality, the greater the compression ratio.
If enabled and Convert pasted images to JPEG
setting is enabled, images drag&dropped into the editor will be converted to JPEG.
If enabled, only image files will be renamed.
If disabled, all attachment files will be renamed.
If enabled, pasted copied files with known names will be renamed.
If disabled, only clipboard image objects (e.g., screenshots) will be renamed.
If enabled, attachments dragged and dropped into the editor will be renamed according to the Pasted File Name
setting.
If enabled, attachments processed via Collect attachments
commands will be renamed according to the Pasted File Name
setting.
When you are pasting/dragging a file with the same name as an existing file, this separator will be added to the file name.
E.g., when you are dragging file existingFile.pdf
, it will be renamed to existingFile 1.pdf
, existingFile 2.pdf
, etc, getting the first name available.
Default value is
(space
).
If enabled, empty attachment folders will be preserved, useful for source control purposes.
If enabled, when the note is deleted, its orphan attachments are deleted as well.
The following tokens can be used in the Location for New Attachments and Pasted File Name settings.
The tokens are case-insensitive. The formats are case-sensitive.
-
${date:format}
: Current date/time using Moment.js formatting. -
${fileCreationDate:format}
: File creation date/time using Moment.js formatting. -
${fileModificationDate:format}
: File modification date/time using Moment.js formatting. -
${fileName}
: Current note filename. -
${filePath}
: Full path to current note. -
${folderName}
: Current note's folder name. -
${folderPath}
: Full path to current note's folder. -
${frontmatter:key}
: Frontmatter value of the current note. Nested keys are supported, e.g.,key1.key2.3.key4
. -
${originalCopiedFileExtension}
: Extension of the original copied to clipboard or dragged file. -
${originalCopiedFileName}
: File name of the original copied to clipboard or dragged file. -
${prompt}
: The value asked from the user prompt. -
${randomDigit}
: A random digit. -
${randomDigitOrLetter}
: A random digit or letter. -
${randomLetter}
: A random letter. -
${uuid}
: A random UUID.
You can define custom tokens in the Custom tokens
setting.
The custom tokens are defined as a functions, both sync and async are supported.
Example:
exports.myCustomToken1 = (substitutions, app, format) => {
return substitutions.fileName + app.appId + format;
}
exports.myCustomToken2 = async (substitutions, app, format) => {
return await Promise.resolve(substitutions.fileName + app.appId + format);
}
Then you can use the defined ${myCustomToken1}
, ${myCustomToken2:format}
tokens in the Location for New Attachments and Pasted File Name settings.
substitutions
: is an object with the following properties:fileName
: The filename of the current note.filePath
: The full path to the current note.folderName
: The name of the folder containing the current note.folderPath
: The full path to the folder containing the current note.originalCopiedFileExtension
: Extension of the original copied to clipboard or dragged file.originalCopiedFileName
: File name of the original copied to clipboard or dragged file.
app
: Obsidian app object.format
: optional format string.
All notable changes to this project will be documented in the CHANGELOG.
Custom Attachment Location
is available in the official Community Plugins repository.- Beta releases can be installed through BRAT.
Maintainer: Michael Naumov