Action

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

Posted by sorashima, Last update over 2 years ago

UPDATES

over 2 years ago

Translate comments in the shortcut to English.

show all updates...

over 2 years ago

Translate comments in the shortcut to English.

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

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

over 2 years ago

Changed the discription.

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