Hurry up and wait and script

I’m currently involved in a project at work that involves a lot of hurry up and wait. One minute I’m running around putting out a dozen fires, the next I’m stashed in my office waiting for the next Most Important Thing In The Worldâ„¢.

During one of my “wait” moments, I found myself going through some old project notes I’d kept in MacJournal. Since I use Journler now, I looked at exporting from the former and importing to the latter.

Unfortunately, MacJournal doesn’t set the the date created and date modifed on the exported files (it puts the info into the content of the file instead). So I looked at scripting it, and came up with a brain-dead AppleScript to do the deed. This is one of those scripts you write for one-time use, just because you can:

tell application "MacJournal"
  
  set theJournal to the journal named "_Archived"
  
  repeat with entryNumber from 1 to (count of journal entries of theJournal)
    
    set theEntry to journal entry entryNumber of theJournal
    set {entryName, entryCreatedDate, entryModifiedDate, entryContent} to {name, date, modification date, plain text content} of theEntry
    
    if entryContent is missing value then
      set entryContent to " "
    end if
    
    tell application "Journler"
      make new entry with properties {name:entryName, date created:entryCreatedDate, date modified:entryModifiedDate, contents:entryContent, category:"Imported From MacJournal"}
    end tell
    
  end repeat
end tell

Pretty straightforward. The only curiosity was I had was that an empty MacJournal entry (that is, one without any content) would be reported either as contents:missing value or contents:"", but it wasn’t clear to me when each happened, nor the actual difference. Journler doesn’t apparently know what “contents:missing value” means, so I had to turn it into something Journler did understand, thus this code:

    if entryContent is missing value then
      set entryContent to " "
    end if

In early testing, I replaced contents:missing value with contents:" " (a space) because using an empty string (contents:"") generated an error. Later testing (with different content) didn’t have this error. I didn’t spend the time to  figure it out. After all, this was a one-off script to solve a one-time problem. In fact, I’ve probably spent more time writing about the script than I did writing the script itself.