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 :smiling_face_with_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
4 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

This is EXACTLY the shortcut I was looking for when trying to justify signing up for Bear!

I collect notes from other tools, but wasnt looking forward to manually copy/pasting into Bear.

Now - I think - I can just export from my other tools into that iCloud location and automate the import. Fantastic!

1 Like

Just tried this and it worked beautifully. One thing tho - if the markdown note contains an image, it embeds the image in the bear note (great) but then it also creates another bear note with just in the image in it? I cant work out how to stop that

Also, how do I make the markdown file name the note name in Bear?

Thanks again!

Hi @roar I have this set up on my iCloud and it works really well. I just duplicated the shortcut and the Python in the Automator so I could do the same thing for a Google Drive location. The shortcut works manually but for some reason the Automator isn’t activating when a file goes into the folder. Is there anything specific I need to do about Google Drive or any modifications?

This works well. I assume we could change the shortcut to delete the files which have been left in the processed folder as I do not need them in Bear as well as a different folder. Also there is an option in Shortcuts called Automation which looks like it would do the job of the automator action keeping the whole process just as a shortcut?

My personal approach is to use Hazel both to move pdf files from my downloads folder to the Bear Import folder and then run your script to activate the shortcut. This is simply because I am used to using Hazel.

As a non coder it did take me a while to work out that I had to download python3 in order to run the script.

Thanks for this - very helpful and a key in helping me transition from Evernote.