Action

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

Posted by sorashima, Last update 8 months ago

UPDATES

8 months ago

Translate comments in the shortcut to English.

show all updates...

8 months ago

Translate comments in the shortcut to English.

8 months 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.

8 months 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.

10 months ago

Changed the discription.

10 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:

https://www.icloud.com/shortcuts/e631aa3f51cd497dbb046461ef3ff739


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
    true

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.