• Announcements

    • gbarry

      Reach out to Evernote support on Twitter @EvernoteHelps   09/20/2016

      We've been leveling up our support across all channels. If you're active on Twitter, try your hand with our @evernotehelps feed. It's helmed by a crack team out of Austin, TX who are here to answer your questions. They're generally active from 7am-4pm CST.  https://twitter.com/evernotehelps  
Scooter

Applescript Help

11 posts in this topic

I have a lot of notes that come into Evernote from various automatic sources (drops into a specific folder, IFTTT, etc.)  I'd like the bone of an Applescript that would help me organize this mess, all of which piles up in my inbox.  Most of these automatic things are arranged to put specific tags on notes as they are created.  I would like to create a Applescript that will search all my notes, find ones tagged with a particular tag, the rename that note with a title and a modified version of the note creation date.  Finally I'd like the original tag deleted and new ones applied and have it moved into a specific folder.  I know how to do a lot of that, but some things (like parsing out the creation date and reformatting it) it beyond me.  Can anybody help with this?

Share this post


Link to post

Posted (edited)

22 minutes ago, Scooter said:

I have a lot of notes that come into Evernote from various automatic sources (drops into a specific folder, IFTTT, etc.)  I'd like the bone of an Applescript that would help me organize this mess, all of which piles up in my inbox. 
. . .
  I know how to do a lot of that, but some things (like parsing out the creation date and reformatting it) it beyond me.  Can anybody help with this?

I can probably help.  Please post the script (in a zip file if you prefer) you have so far, and add comments in it where you need help.  May I suggest this form of a comment:

### HELP:  Describe the issue, error, problem, or action you want.
# If you need multiple lines, start each with the # symbol.

In case you don't know, the # symbol is an alternate to -- as a comment indicator.

Also, if you have not already done so, I highly recommend installing the Satimage.osax (Free D/L & info at  http://tinyurl.com/Satimage-Osax-DL ) scripting addition.  It has excellent RegEx find/change tools, as well as date formatting and string and list handling.  It has been available for years now, and is highly reliable and safe.

Good luck.  Everything you asked for seems very doable to me.  If I don't respond quickly to your follow-up post, feel free to PM me.

~~~~~~~~~~~~~~~~~~~~~~~~~~~

EDIT:  2017-08-11  2:34 AM CT

Also, I will need some good, real-world sample data.  It would be great if you could export to ENEX a good sample of Notes that you want to process, and upload them in a zip file (in a PM to me if you prefer).  Of course I'll need a table of the old to new tags.

Edited by JMichaelTX

Share this post


Link to post
18 hours ago, Scooter said:

I would like to create a Applescript that will search all my notes, find ones tagged with a particular tag, the rename that note with a title and a modified version of the note creation date.  Finally I'd like the original tag deleted and new ones applied and have it moved into a specific folder.  I know how to do a lot of that, but some things (like parsing out the creation date and reformatting it) it beyond me.  Can anybody help with this?

My Process-Inbox script is documented at https://www.evernote.com/l/AArgmVF4KRhEObasbIU6rAVTET15Wre7odI

In my script, I parse and reformat dates with code
      set {year:yyyymonth:mmmday:dweekday:ddddto (current date)
      set 
dd to ("0" & d as string)
      set 
dd to (text -2 thru -1 of ddas string
      
set m to mmm as integer
      
set mm to ("0" & m as string)
      set 
mm to (text -2 thru -1 of mmas string
      
set yyyymmdd to (yyyy as string) & "/" & mm & "/" & dd

The date parsing was easy but further work was required to obtain a 2 digit month/day

My script operates on the selected note, but a search string can be applied using code such as
        tell application "Evernote" to set theNotes to find notes ("tag:xxxxx")

I've deleted tags using the code
         unassign tag "!Type-Templates" from newNote


 

Share this post


Link to post

Here's an easy way to get the ISO date format from an AppleScript date:

set dateISOStr to text 1 thru 10 of ((current date) as «class isot» as string)
-->2017-08-11

 

1 person likes this

Share this post


Link to post

Great.  Thanks for the help.  Those work great.  Is there a way to pull out the 'created date' from a note, rather than the current date?

Share this post


Link to post

I don't actually have a complete script.  But I've designed several others to import files, assign tags, etc.  What I really can't figure out is how to pull the created date out of the notes, and to search for a given tag.

Share this post


Link to post
Just now, Scooter said:

Is there a way to pull out the 'created date' from a note, rather than the current date?

Sure.

set creationDate to creation date of oNote

 

Share this post


Link to post
9 minutes ago, Scooter said:

What I really can't figure out is how to pull the created date out of the notes, and to search for a given tag.

Select one Note in EN Mac, and run this from the Script Editor:

tell application "Evernote"
  
  set noteList to selection -- Notes selected by User in UI
  --      OR --
  --set noteList to (find notes "notebook:.Inbox") -- Same as Search Box in UI
  
  set numNotes to count of noteList
  log "Num of Notes: " & numNotes
  
  set noteIndex to 0
  
  repeat with oNote in noteList
    
    set noteIndex to noteIndex + 1
    
    tell oNote
      set noteTitleStr to title
      set creationDate to creation date
      set modificationDate to modification date
      set NBName to name of notebook of oNote
      set tagList to tags -- get list of tag objects
    end tell
    
    
    ### Instead of the repeat loop, seems like some type of "every" statement should work, like this: ###
    #    set tagNameList to (name of every tag in tagList as list)
    #    log tagNameList
    
    (* --- NOTE PROPERTIES ---
    altitude, creation date, ENML content, HTML content, latitude, longitude, modification date, note link, 
    notebook, reminder done time, reminder order, reminder time, source URL, subject date, tags, title
    
    -- AVAILABLE, BUT NOT DOCUMENTED --
    active, author, class, content class, guid, id, place name, source, source application
    *)
    
    log "[" & noteIndex & "]: " & noteTitleStr
    log "       • Notebook:  " & NBName
    log "       • Created :  " & creationDate
    log "       • Last Mod:  " & modificationDate
    
  end repeat
  
end tell -- Evernote 

 

Share this post


Link to post
16 minutes ago, Scooter said:

What I really can't figure out is how to pull the created date out of the notes, and to search for a given tag.

tell application "Evernote" to set theDate to creation date of theNote

tell application "Evernote" to set theNotes to find notes ("tag:xxxxx")

 

Share this post


Link to post
15 minutes ago, Scooter said:

search for a given tag.

  set noteList to (find notes "tag:EN.Mac")
  
  set numNotes to count of noteList
  log "Num of Notes: " & numNotes
  
  
  set noteIndex to 1
  set oNote to item noteIndex in noteList

Replace the "set noteList to selection " and the repeat loop with the above to search for a tag.  The search criteria is identical that that you type into the EN Mac Search box.

Share this post


Link to post

Fantastic.  Let me work on this for a day or two, but that looks simple.  Thanks!

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