obsidian-custom-attachment-location
obsidian-custom-attachment-location copied to clipboard
Support date var template(moment.js) in folder path & image name
Support Date Template Variables in Path by Changing getAttachmentFolderPath
/getPastedImageFileName
Behavior
For example: /dir1/${date:YYYY}/${date:MM}/${filename}
will be transformed to /dir1/2024/03/target_file/
Implementation Details:
- Use a regex pattern to match date variables (vars starting with ${date:} / ${filename}).
File Attachment Folder Behavior:
- If the file already has an attachment folder: Use the earliest folder that matches the regex.
- If the file has no attachment folder (no folder matches the regex): Create a new one using the current date and time.
Important Notes:
-
getAttachmentFolderPath
will become asynchronous, so adjust the invocation timing in the handlePaste event accordingly. - Only support fixed digit formats in
${date:}
like YYYY, MM, DD, Q. (${date:YYYY}
will compile tod[4]
regex for matching earliest attachment folder)
conf example: