Jump to content
dyb_dzo

ANSWERED Check if a note exists / AppleScript

Recommended Posts

I want to check if a note with a given name already exists:

	tell application "Evernote"
		if note named thisTitle exists then
			tell note named thisTitle to append html "<strong>exists</strong>"
		else
			set note1 to create note title thisTitle with text thisContent as string notebook "DAILY"
			assign tag "PDF" to note1
		end if
	end tell

But it gives me error:

Evernote got an error: Can’t get note "[thisTitle]"

 

How do i check if a note exists?

 

Share this post


Link to post
On 7/4/2016 at 0:13 PM, dyb_dzo said:

How do i check if a note exists?

This script on my Github Gist should give you a good idea of how to do this:

EN Mac Append Note OR Create New Note (AS).applescript

Please let me know if you have any questions or issues.

DISCLAIMER:

• This script is provided for EDUCATIONAL PURPOSES ONLY
• It has had very limited testing, and may contain errors & bugs
• The user of this script assumes all risk and liability
• This script does write to your Evernote account, so it is best to first test using a Test Account

  • Like 1

Share this post


Link to post

Your solution looks quite robust!

 

It's probably too much for my needs but i see where it could be usefull. Thank you!

It also opened my eyes for what i was doing wrong.

Before your post i found out how to search for notes but that didn't work as well.

 

My bit of code:

_

set foundNote to get every note of notebook "DAILY" where its title is searchForThisTitle

if foundNote is {} then

         –– create new note and do stuff with it

else

     set myNote to item 1 of foundNote

         –– do stuff to the existing note

_

 

 

I missed the part "item 1 of" – instead of picking an item from the foundNote i was just referencing to the found set.

 

 

My question was derived from "if note named thisTitle exists then" but it seems like i should utilize the search function from the beginning.

Share this post


Link to post
1 minute ago, dyb_dzo said:

My question was derived from "if note named thisTitle exists then" but it seems like i should utilize the search function from the beginning.

Likewise, I could never get the "if exists" code to work
I use the search function

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...