Action
Copy images from Drafts' Previews folder to Obsidian vault's assets folder
UPDATES
about 3 years ago
Translate comments in the shortcut to English.
about 3 years ago
Translate comments in the shortcut to English.
about 3 years ago
The Drafts action directory automatically inserts its own URL at the beginning of the markdown link, so you had to manually remove it after copying the shortcut URL. Fixed it.
Now, when the processing of Shortcuts app is completed, the processing automatically returns to Drafts.
about 3 years ago
The Drafts action directory automatically inserts its own URL at the beginning of the link, so I replaced the shortcut URL with plaintext instead of the link format.
Now, when Shortcuts finishes processing, it will return to Drafts.
about 3 years ago
Changed the discription.
about 3 years ago
Rename this action.
Copy images from Drafts’ Previews folder to Obsidian vault’s assets folder
This Drafts action + shortcut does the following:
- Extract the image links written in the draft by Draft Actions: Save images in Drafts’ Previews folder.
- From them, get the image files saved in the Previews folder of Drafts (iCloud Drive / Drafts / Library / Previews /).
- Copy them to the Obsidian assets folder (iCloud Drive / Obsidian / {Vault folder} / assets or (in this iPhone | in this iPad) / Obsidian / {Vault folder} / assets).
Shortcut:
https://www.icloud.com/shortcuts/e631aa3f51cd497dbb046461ef3ff739
Example of use
This draft contains links to the image files (inserted by the action “Save images in Drafts’ Previews folder”). Execute this “Copy images from Drafts’ Previews folder to Obsidian vault’s assets folder” action.
Among the image files saved in the Previews folder of the draft, the files with the links written in the draft are…
copied to the assets subfolder of the Obsidian vault.
This action + shortcut just copies the image files to your Vault’s assets folder. To save the text in draft, use Save in Obsidian Vault | Drafts Directory separately.
When you launch the Obsidian app and open the memo, the memo is displayed with an image.
Initial setting
Tap here for “Get file from” action on the shortcut.
Select the Previews subfolder in the Library subfolder of iCloud Drive’s Drafts folder, and click Done.
Tap here for “Save to” action on the shortcut.
Select the assets subfolder in the vault folder in the Obsidian folder in iCloud Drive or this iPhone / this iPad and click “Done”.
https://sorashima.hatenablog.com/entry/ObsidianImagePreviewOnDrafts
Steps
-
script
const fnA = [...draft.content.matchAll(/!\[.*?\]\((.*?)\)/g)].map(fn => fn[1]) const fnO = {fn: fnA} draft.setTemplateTag("Dic", JSON.stringify(fnO))
-
runShortcut
shortcutName CopyPreviewsImgs2AssetsFolder
waitForResponse true
Options
-
After Success Default Notification Info Log Level Info