PopClip extension

I couldn’t find a PopClip extension for Tinderbox, so during a particularly dull meeting, I came up with this little bit of AppleScript.

It looks for .tbx file in your Documents folder called, ahem, “WorkingMemory.tbx”, and if it finds it opens it, and if it doesn’t creates it… and then pastes the selection that was current when you invoked PopClip into a timestamped note, ready for processing…

If you have PopClip installed, save this as “SaveToTBX.popcliptxt”, open it, and PopClip should do the rest. You’ll have to run the guantlet of System Events security the first time you run it, but I’ve been using it all afternoon and it’s been working a treat.

-- #popclip
-- name: SaveToTBX
-- icon: symbol:shippingbox
-- language: applescript

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set notesPath to (path to documents folder as text) & "WorkingMemory.tbx"

tell application "System Events"
  set fileExists to exists file notesPath
end tell

tell application "Tinderbox 10"
  activate
  if fileExists then
    -- If the file exists
    open file notesPath
    activate
  else
    -- Then open the newly created file in TinderBox 10
    set myNewDocument to make new document with properties {name:"Momento Mori"}
    save myNewDocument in POSIX path of notesPath
    
  end if
  
  tell front document
    set timestamp to do shell script "date '+%Y-%m-%d %H:%M:%S'"
    set myNewNote to make new note with properties {name:"My New Note " & timestamp}
    tell myNewNote
      set text of myNewNote to "{popclip text}"
      set value of (attribute named "Badge") to "document2"
    end tell
    save
  end tell
  
end tell

9 Likes