A macro view of the past

It’s ironic that after 25 years, I find myself returning to Mac macros. Way back in college I worked in the Carleton bookstore, which bought some new-fangled database software to run its billing/shipping/inventory. Since I was more Mac-savvy than most of the adult full-timers, I was in charge of creating a few macros to speed up some of the data entry. I don’t know how useful my initial experiments were. I hope I wasn’t to blame for all of the inventory miscounts we had – you’ve never seen so many “Quantity: -1” records in your life. It certainly couldn’t have had anything to do with the foolproof system we used: we would ring up the price of each book on the NCR cash register, complete the sale, and then write down the ISBN of each book on a pad of paper by the register. At the end the day, or during a lull, somebody would walk over to the Mac Classic and enter in the day’s ISBN numbers. I still say the best skill I acquired from my early days in retail was to use the numeric keypad.

So now I find myself back with an iMac, and an extended keyboard with a numeric keypad, finally returning to the concept of macros. Sure, macro programs have been around for a while, but I guess I’d become inured to the drudgery of repetitive data entry. No more.

So now I’m using Keyboard Maestro to create macros for repetitive tasks that need doing in DT. They probably are also possible if you know Applescript, but I don’t. I do know, however, how to press keys. As long as food pellets or power-ups are involved.

Most importantly, I realized that even though DT doesn’t provide a way to batch edit documents’ metadata, I could create a simple macro that would carry out the 10+ steps required to add the metadata for a single record: open Document Properties of selected record, wait .25 seconds, tab down 5 times to get to the Keyword metadata field, type in “note” (or a separate macro for “thought”, for “map”…), close the window, and go to the next record.

Now if I can only figure out how to do it for multiple selected records, some kind of macro loop.

We’re getting closer, people.

Advertisements

Tags: ,

14 responses to “A macro view of the past”

  1. jostwald says :

    I should probably have pointed out that you need to vary the number of tabs in your macro, depending on what type of file you’re using it on. For example, an .rtf needs 5 tabs to get to the Keyword field, but a PDF would only need 3, since it doesn’t allow as many metadata fields. Kinda obvious once you start testing the macro, but still.

  2. Björn Thegeby says :

    Whippersnapper!

    In my day we punched socio-economic data onto Hollerith cards for the Tuesday “computer run”. If we were really lucky the would be a CORRELATION on one of the fanfold printouts we could pick up on Wednesday. …and there was much rejoicing 🙂

    • jostwald says :

      Another tweak for the Keyword macro: with KM you can assign different macros to the same key (I try to have all my macros and Applescript shortcuts Ctl-Opt-Cmd-whatever, just to remember them easier), and a popup menu will then appear with all the sub-options. So I type Ctl-Opt-Cmd-K (for the Keyword metadata field) and a popup menu prompts me to type one more letter to chose whether I want a Note, a Thought, a Map, a Pic…

  3. jostwald says :

    Another macro can copy the name of a file and paste it into the content. Since I name files with meaningful names (e.g. “Marlborough claims Ramillies was decisive”), and since the AI only looks at the text in the content and not the file name, I title a new file, then press Ctl-Opt-Cmd-V. This selects the title of the record (with a simple Return when the file is already selected), copies it, jumps down to the content pane (Ctl-Tab), and pastes it. Again, nothing revolutionary, but saves me 3 steps each time I use it.

    • jostwald says :

      And then you start combining your macros into larger groups. Wanna create a new Note and fill out some of the metadata automatically? Macro it up. Create a new rich text note, prompt for the doc name, and when you press Enter that triggers the macro to copy the title text to the content of the document, and then opens up the Properties box and enters “note” in the Keyword field, closes it and it brings you back to Go. About 17 keystrokes saved right there. And it has the additional advantage of alleviating the need for you to remember so many different key combinations if you group them together.
      Make a similar macro (Ctl-Opt-Cmd-T) that will create a new Thought document. Make a bunch and assign them all the same key command and the sub-menu will pop up. Kaizen!

  4. jostwald says :

    Need another? Change your documents to the same font and size (my eyes! my eyes!). Add a new format with Format-Style-Styles-Add to Favorites based off some selected text. Create a Systems Pref-DTPO application keyboard shortcut. Then, with a document selected, have your macro type Ctl-Tab to the content pane of the selected document, Select All of the content, and apply your Favorite Style, before typing the left-arrow key (so you don’t accidentally delete all the text), a return for good measure, and then save the doc. Tab-Ctl three times, down arrow and you’re at the next record, ready to go. Again, there may be a more elegant way to do this in Applescript or Automator, but I’m a busy man.
    [Edit: The key command shortcut to Apply your style only works if you have the Ruler displayed]

  5. jostwald says :

    Or one more. I’ve imported in a bunch of PDFs that I downloaded from Google Books. They all have that annoying first page of boilerplate, which it turns out is actually text, which means DTPO’s AI picks up on it. So I created a macro to Show in Finder a selected PDF in DTPO. Then in Finder, Open With Adobe Acrobat Pro – modifying PDFs in Preview and in DT seems to bloat the PDF file size many-fold for some reason. Then in Acrobat I display the Navigation pane, since the default is to have it hidden. At that point the macro ends: I can choose the pages to delete (sometimes the PDF is from a source like the BL where the boilerplate text is at the end of the document), and save the file. I also tend to delete blank pages as well. More drudgery avoided.

  6. jostwald says :

    Now we’re getting somewhere. I’m reading an image PDF in a DPTO separate window – zoomed in so you can actually decipher the d-mn’d handwriting. I want to make a note or transcript of a section on that page. There is an Annotation feature in DTPO, but I don’t like it for many reasons. So instead I found some code on the Script forum that will Copy Page Link and I combined it with my Create New RTF note. I Execute Applescript as the first step in a macro that then closes the window (not ideal), creates a new RTF document in DTPO, prompts me to title it before then pasting the page link into the content pane, and finishes it off with tagging the Keyword field as “note.” I can then take whatever notes I need. I should probably figure out how to change the window focus rather than close the zoomed-in PDF window, but for the time-being I can just click on the page link and it’ll take me back to the PDF page I was just on.

  7. jostwald says :

    Another point worth mentioning: from what I’ve read, Applescript is unable to write to the OS X metadata fields. But since macros (like Keyboard Maestro) replicate keystrokes, they can, at least record by record. Still working on the batch part.

    • jostwald says :

      Finally spent the time to figure out (i.e. debug) the Batch feature of KM. Here’s the action sequence for opening up X number of PDF records and pasting a value (in this case, “ps” for primary source) into the Keyword property in Adobe Acrobat Pro. Doing this in Adobe is better than in DT, because whenever you make changes to a PDF file in DT the file size increases several fold; my 300 kb PDFs only add 3-4 kb when done through Adobe. Since I have 10,000 PDFs of individual issues of newspapers, and my database is already at 114 GB, I don’t need that. Doing this for 10 records takes about 50 seconds (doing one record by hand takes about 15 seconds, so the macro saves about 100 seconds for ten records, not to mention saving your hands/fingers and allowing you to multi-task). Of course you can increase the number of records, and do something else while it churns away…
      KM macro to batch add keywords to PDFs
      Make sure you’ve selected the top record in the middle pane of 3-pane view, and all of the records below it are PDFs (vs RTFs, etc.) – sort by Kind column if needed.
      Note in the above macro that I tried to select menu options instead of relying on key shortcuts – it’s probably more accurate that way, and less likely to go off the rails.
      Note as well that you need to make sure your column sort order won’t move the changed record to a different part of the list – that may screw up which records it tries to change next.

    • jostwald says :

      Figured out the batch part. See my comment in the https://jostwald.wordpress.com/2014/01/31/a-macro-view-of-the-past/ thread.

  8. jostwald says :

    Another tweak: since making changes (including adding metadata) to PDFs in DTPO vastly inflates the size of PDF files (and my WSS database is already running at 88 GB), I made a different, more complicated, macro to add “ps” (primary source) to the Keyword metadata field of original PDFs. Doing it in the native Adobe Acrobat Pro, which won’t inflate the file size. Select Menu Item Data-submenu Open With-[type Adobe Acrobat Pro in third submenu spot just as it appears in the menu]. Then open Properties in Adobe Acrobat Pro, tab to the Keyword field, type “ps”, tab to click on the OK button, save the document, close the document, and then Activate DTPO to return back.

  9. Dellu says :

    Can you post these macros in here?
    I didn’t understand how KM works; I totally fail to copy the file names into the content of the file

Trackbacks / Pingbacks

  1. Keyboard Maestro + Devonthink | Skulking in Holes and Corners - April 28, 2014

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: