Action

Copy images from Drafts' Previews folder to Obsidian vault's assets folder

Posted by sorashima, Last update about 2 months ago

UPDATES

about 2 months ago

Changed the discription.

show all updates...

about 2 months ago

Changed the discription.

about 2 months ago

Rename this action.

Copy images from Drafts’ Previews folder to Obsidian vault’s assets folder

This Drafts action + shortcut does the following:

  1. Extract the image links written in the draft by Draft Actions: Save images in Drafts’ Previews folder.
  2. From them, get the image files saved in the Previews folder of Drafts (iCloud Drive / Drafts / Library / Previews /).
  3. 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: CopyPreviewsImgs2AssetsFolder


Example of use

0
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.

1
Among the image files saved in the Previews folder of the draft, the files with the links written in the draft are…

2
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.

3
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
    false

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.