エンジニアのソフトウェア的愛情

または私は如何にして心配するのを止めてプログラムを・愛する・ようになったか

テキストファイルをAppleScriptでEvernoteへ

最近になって osascript というコマンドの存在を知りました。


と、いうわけで。

テキストファイルをEvernoteに送るAppleScriptを書いてみた。

ちなみに。shebangに対応しているようで、実行可能なファイルにしておいて1行めに#! /usr/bin/osascriptを書くとコマンドとして実行してくれる模様。

#! /usr/bin/osascript

on run argv
  repeat with arg in argv
    try
      open for access arg
      set note_text to read arg
    end try
    close access arg
    
    tell application "Evernote"
      create note title paragraph 1 of note_text with text note_text
    end tell
  end repeat
end run


toevernoteという名前で保存したら。実行可能に設定する。

$ chmod +x toevernote 


試しに自分自身をEvernoteに保存してみる。

$ ./toevernote toevernote 
note id x-coredata://DF490DD9-C557-490B-B98F-2BA0DC0D8517/ENNote/p31233 of notebook 000.inbox

なんかログが出た。
create noteをすると、ログが出るようです。詳しくはまだ追いかけてないです。


それはそれとして。とりあえず保存することはできました。