Bear Inbox – a Workflow/Shortcut importing any kind of files into Bear Notes

Bear Inbox Import

Bear Inbox Import - v. 1.4.4 - 2024-11-11 at 18:16 EST

Here is a workflow where you can paste files into a folder (Bear Inbox) on Mac, iPad, iPhone, Windows (synced by iCloud Drive or Dropbox to a Mac) or Linux (synced by Dropbox to a Mac). They will then appear in Bear as notes (if plain text) or as notes with file attachments (if other kind of files).

Shortcut

Download and install: Bear Inbox Import - Apple Shortcut

Note! Run shortcut maually on different file types some times, to set permissions before using Automator (explained below)

Features

Files Imported to Bear:
All imported notes get tagged with #.inbox

  • Plain text files (.txt, .md, markdown) are all imported as regular Bear Notes
  • Images into single note (when several are posted together)
  • Files like .textbundle, .textpack, .bear, .panda are imported as Bear Notes with images and attachments.
  • All other files are embedded as file attachents (several in same note, if posted together)

Run automatically with Folder Actions in Automator on MacOS only (see below).
Or run manually on Mac, iPad or iPhone.

Create and set inbox folder Bear Inbox on either:

  • iCloud Drive (Mac, iPad, and iPhone)
  • Dropbox (Mac only)
  • Google Drive (Mac only)
  • Other folders – Local or Cloud synced (Mac only)

Bear Inbox Import - Apple Shortcut
Note: When using iCloud Drive, this shortcut will work manually or scheduled on iPad and iPhone as well.

Automator Folder Action

This will monitor the “Bear Inbox” folder and trigger the shortcut.

  1. Open Automator and create a new Folder Action:
  2. Chose folder: “Bear Inbox” (same folder as the Shortcut above uses
    (on iCloud, other cloud or local HD)
  3. Add action: Run Shell Script and choose Shell: python3
    (delete default code)
  4. Copy and paste the Python code below to the Run Shell Script action above:
import os
import time
from pathlib import Path

home = str(Path.home())
lock_file = home + '/Library/Mobile Documents/com~apple~CloudDocs/Bear Inbox/lockfile.log'

if os.path.exists(lock_file):
    pass
else:
    # file_path does not exist
    with open(lock_file, 'w') as file:
        file.write('Block multi run of shortcut!')
    time.sleep(10)
    os.system('shortcuts run "Bear Inbox Import"')
    # The "Bear Inbox Import" Shortcut will delete 
    # 'lockfile.log' at the end of run

  1. Save as Bear Inbox.workflow:
  2. “Throw” any file into the Bear Inbox folder and see how it runs :sunglasses:

Comments

If you want to run this shortcut/workflow on a different folder than “Bear Inbox” on “iCloud/”, you have to change to a new path in:

  • Bear Inbox Import - Shortcut,
  • Automator Folder Action
  • and the path for the lock_file in Python Code
2 Likes

This looks useful! Just one note - you create the inbox folder in the iCloud Drive. I have learnt from experience that it’s not wise to use iCloud for automated stuff. It can get out of sync. if you perform lots of file operations automatically, and that can screw up your iCloud syncing. You can even potentially lose files. I now only do automated stuff on the local drive.

1 Like