Help us understand the problem. What is going on with this article?

Macのメモ(Notes.app)から全テキストを取り出す JXA

Mac のメモアプリから全テキストを取り出す

 iPhone, iPad や Mac で使用しているメモアプリ(Notes.app)内の全てのメモからタイトルと本文(テキストの見)を取り出すJXA (JavaScript for Automation) です。
 メモに入っているノートのタイトルと本文(テキストのみ)を取り出して、テキストエディタアプリに貼り付けます。
形式はタイトルを「【」と「】」で囲み、改行して本文のテキストが続きます。
分けたい方は「【...】」で検索して分けることできるでしょう。

ソース(JXA)

 コードは単純ですので、好きなように改変して利用してください。

getNotes.scrpt
var app = Application.currentApplication()
app.includeStandardAdditions = true

var noteApp = Application("Notes")

noteApp.activate()
delay(2)

var folders = noteApp.folders
var results = ''
for (eachFolder in folders) {
    var notes = folders[eachFolder].notes
    for (eachNote in notes) {
        var noteName = notes[eachNote].name()
        var noteText = notes[eachNote].plaintext()
        results = results + "\n" + noteName + "\n" + noteText
    }
}

var textEdit = Application("TextEdit");
textEdit.activate() 
delay(2)
var doc = textEdit.Document(); // 新規にドキュメントを作成
textEdit.documents.push(doc); // 画面に表示する
doc.text = results      // TextEdit に結果をセットする
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした