Scripting Scapple and allowing .scap file updates from other processes ?

On macOS, if the same plain text file is open in two different applications at the same time ( like BBEdit and TaskPaper for example), changes saved to file by one app (or by a script process) are updated in the display of the other within a second or so.

Q: Is there any way of enabling this behaviour for Scapple ?


I have written some scripts which parse both .scap file XML, and any Scapple content (com.scapple.internal.pboardType) in the clipboard.

These let me:

  1. Create a linked Scapple sub-file for a selected node in a scapple diagram, and
  2. Save as OPML with nested indents where the Scapple content is ‘acyclic’ (consists of tree-like structures rather than loops)

I would, however, also like to be able to script some graphic rearrangements - for example, updating note position information in the XML file to tidy a tree diagram while it is open, and get updates on the screen without having to repeatedly go through the Save -> Dialog -> Accept sequence.


On Scapple, the default behaviour when the XML of an open .scap is changed externally (by an another app or script) is:

  • No immediate update of display, and
  • user choice dialog on next Save,

Screen Shot 2018-06-14 at 08.52.21.png

Scapple does, however, automatically update the display when a .scap file is changed by a second running instance of Scapple

(We can open the same .scap in two different instances of the Scapple app using a Bash shell line like:

open -n -a Scapple "$HOME/Desktop/dag.scap"


In other words:

  1. Scapple CAN immediately update a display when it notices a file change,
  2. But, by default, it only does so when the change is made by a process which is owned by another Scapple instance.

Is there any way of allowing it to accept file changes made by other processes, in the manner of BBEdit etc?

It looks like the main difference isn’t which program does the editing, but how the program does the editing. For example, try loading the .scap file in TextEdit and modifying the contents of a note in the XML, then save it. The change should immediately appear in the Scapple window.

Now with both windows open, edit the .scap file using Vim, Emacs or whatever you prefer on the command-line. After saving the changes there, go back to TextEdit and try to modify and save the file, you will get this dialogue box, as you will in Scapple.

In short Scapple is using the basic macOS interfaces for managing an open file. It benefits from the notification infrastructure used by other Cocoa applications (including Scapple) to keep the open instance up to date.

BBEdit, and it looks like Taskpaper as well, likely have additional code in place to handle file system changes outside of that framework. This is not an uncommon thing to do with a coding editor, and given the design intent of TaskPaper, I bet there is similar code in place as well.

While it would slow down your script a bit to do so, I wonder if committing the changes to the disk using something that works through the macOS infrastructure would improve things? I haven’t tested it, but maybe using the AppleScripting bridge could work.

Delegating the write to TextEdit works well. Thank you !

sorry, dummy user here…
“For example, try loading the .scap file in TextEdit and modifying the contents of a note in the XML, then save it.”
If I open .scap file in TextEdit I see coded XML file… is that correct?

I think that was in a diagnostic context – a discussion of how different apps manage the sharing of write permissions.

What are you trying to do ?

actually it refers to your conversation with Amber as shown above…

If I open .scap file in TextEdit I see coded XML file… is that correct?

Certainly .scap files are XML, if it helps to know that, yes.

(Visual Studio Code might be a more helpful editor)

then my question is: do you update the .scap file writing XML code in Textedit (for instance)? and if so, what are the benefits of such an operation?


That wasn’t the context – as I said, the context of experimenting with an open in TextEdit was purely diagnostic (of write-permission management) – perhaps we failed to make that clear.

The scripts which I was writing were for copying OPML or plain text from Scapple in an indented format (with arrow links interpreted as parent → child)

(The built-in export to OPML uses a different design – everything is exported as a flat list).

Is there something you are looking for, or trying to do ?

as many people an integration (a little more hierarchy, just a little) in Scapple files to pass them to other, more structured, apps…
I am very interested in your script, if possible

Bundled here for use with Keyboard Maestro – not sure if that matches your workflow:

Scapple (42.6 KB)

Screenshot 2022-02-14 at 11.54.44

I will tell you in (my) evening… 1pm here

Here, cut adrift from Europe, and floating aimlessly out towards the arctic. (GMT 11:56)

Grunland, Iceland, Alaska?

London (now floating away mid-Altantic)