Getting Stuff Into Yojimbo with AppleScript (Part 1 of 2)
I have become quite the fan of Yojimbo - a ‘digital junk drawer’ application from Bare Bones Software. It is great place to store all those bits and pieces of electronic material that enter your life on a daily basis.
Yojimbo offers a number of different ways of importing your stuff into its database. By ’stuff’ I mean text, PDF and web links (Yojimbo is limited in the types of data it can work with). You can simply drag stuff into Yojimbo’s main window. Alternatively, you can use Yojimbo’s handy Drop Dock. A third method, of which I am a heavy user, is the Save PDF to Yojimbo option that is available from the PDF services menu.
The problem with default methods of importing stuff is that you still have to go back into Yojimbo if you want to add the item to more than one folder collection or to add tags.
Wouldn’t it be nice if you could send an item to Yojimbo, add tags, and file it in the relevant folder collection(s) all in one action? Damn straight it would be!
Below is an AppleScript that will allow you to do just that. This script is taken from a thread at Yojimbo Talk. I simply mashed together two scripts that were posted by Steve Kalkwarf and Kenneth Kirksey and added a few minor changes. I am not a programmer so the script is probably not as clean as it could be.
The script is activated via Quicksilver (QS). QS makes the process of activating the AppleScript and importing your stuff into Yojimbo that much smoother.
Installation
- Open Script Editor found in Applications/AppleScript/
- Copy the code below and paste it into a new script window.
- Name the script Copy to Yojimbo and File and save the script as a script in Macintosh HD/Users/YourAccount/Library/Scripts/ (where YourAccount is the name of your user account on your Mac).
- You’re done!
Code
---------------------------------------------------------- -- Copy to Yojimbo and File. -- -- Save as a script to: -- ~/Library/Scripts/ -- where 'YourAccount' is the name of your user account on -- your mac. ---------------------------------------------------------- on open (theFile) ---------------------------------------------------------- -- set chooseTagsfromList to true if you want -- the script to present you with a list -- of tags to pick from. Set it to false if you want -- to manually enter the tags. -- If you manually enter tags, separate tags -- with commas. ---------------------------------------------------------- -- set chooseCollectionsFromList to true if you want -- the script to present you with a list -- of folder collections to pick from. ---------------------------------------------------------- -- set chooseTheName to true if you want -- the script to present you with a text box -- in which you can rename the item. ---------------------------------------------------------- set chooseTagsFromList to true set chooseCollectionsFromList to true set chooseTheName to false if chooseTheName then set theName to text returned of (display dialog "Name:" default answer "") end if if not chooseTagsFromList then set restoreDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to "," set theTags to text returned of (display dialog "Tags:" default answer "") set the chosenTagList to every text item of theTags end if tell application "Yojimbo" set allTags to name of every tag if chooseTagsFromList then set chosenTagList to choose from list allTags ¬ with title ¬ "Tags" with prompt ¬ ¬ "Choose Tags:" multiple selections allowed true ¬ with empty selection allowed end if set allCollections to (name of every folder collection) if chooseCollectionsFromList then set chosenCollectionList to choose from list allCollections ¬ with title ¬ "Collections" with prompt ¬ ¬ "Add item to which collection(s)?" multiple selections allowed true ¬ with empty selection allowed end if set n to import theFile if chooseTheName then set name of n to theName end if add tags chosenTagList to n repeat with i from 1 to the count of chosenCollectionList add n to folder collection named (item i of chosenCollectionList) end repeat end tell if not chooseTagsFromList then set AppleScript's text item delimiters to restoreDelimiters end if end open
Script Modifications
- If you want to manually add tags (similar to the way you would in del.ico.us) then set
chooseTagsFromListtofalse. Tags have to then be separated by commas (,). - If you don’t want the code to present you with a dialog box so you can rename the PDF then set
chooseTheNametofalse. - If you don’t want to choose folder collections then set
chooseCollectionsFromListtofalse.
How to Use
First, you will probably have to rescan your QS catalogue so that QS can find the script.
- Open Yojimbo. The script won’t work if Yojimbo isn’t open.
- In the Finder select the item (PDF, txt or link) you want to import into Yojimbo. (Yojimbo doesn’t delete or move the original file. It copies the item to its database.)
- Invoke QS. (By default,
Command + space) - Type
CTY. Yojimbo will hopefully displayCopy to Yojimbo and File.scpt. (If QS can’t find the script you may have to rescan the catalogue again. It may also take a couple of attempts to train QS to recognise that when you typeCTYyou want it to find the script.) - Hit TAB
- Yojimbo should display
Open File...If it doesn’t, typeOFand that should work. - Hit TAB again.
- Hit
Command + G. The file that you selected in the Finder should be displayed. Alternatively, you can use theCurrent Selectionproxy object. - Hit ENTER.
- The Yojimbo dock icon should bounce. ALT-TAB to Yojimbo.
- You will be presented with a window titled
Tagswith your Yojimbo tags listed. You can select as many tags as you like by holding down the Command key and clicking the tag names. Alternatively, you don’t have to select any tags. Once you have done that clickOK. - A window titled
Collectionswill ask you which collection(s) you would like to add the item to. Again you can select zero, one or multiple collections. ClickOKonce you’re done. - Your item will have been imported into Yojimbo, added to the collections you selected and tagged as you selected.
Suggestions for Improvement
- Option to add flags.
- Option to encrypt.
- This script only works if you are importing one-item-at-a-time. It would be great if you could grab a bunch of files, tag them and file them into Yojimbo in one motion.
Unfortunately, I am not a programmer. While I will try and figure out a way to implement these changes, don’t hold your breath. But if some kind individual who is knowledgeable in AppleScript wishes to add these features to the script for MLS and our readers that would be greatly appreciated.
Part II - An Improved Save PDF to Yojimbo
Part II shows how to improve Yojimbo’s standard Save PDF to Yojimbo script (from the PDF Services menu), using the same filing and tagging options that I have discussed in this tutorial.
Comments
Comment on this post (no registration required) in the Mac Law Students Forum.