Skip to content

AppleScript creating duplicate notes #6

@Scarvy

Description

@Scarvy

The current AppleScript creates duplicate notes.

tell application "Notes"
-- Ensure the "Readwise" folder exists
set folderName to "Readwise"
set theFolder to missing value
repeat with eachFolder in folders
    if name of eachFolder is folderName then
        set theFolder to eachFolder
    end if
end repeat
if theFolder is missing value then
    set theFolder to (make new folder with properties {{name:folderName}})
end if

-- Attempt to find the note by title in the "Readwise" folder
set theNote to missing value
repeat with eachNote in (notes of theFolder)
    if name of eachNote is "{clean_title}" then
        set theNote to eachNote
        exit repeat
    end if
end repeat

-- If found, append new content, otherwise create the note
if theNote is not missing value then
    set the body of theNote to the body of theNote & ¬
    "<br>" & "<b>{clean_text}</b>"
else
    make new note at theFolder with properties {{name:"{clean_title}", body:"{clean_text}"}}
end if
end tell

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions