bswiss56 8 Posted February 20, 2016 Share Posted February 20, 2016 Hello everyone! I am certainly not a pro in applescript. i am building an export routine in applescript exporting notebook. I know: this has been the content of a few forums already... and it works well. I just want to make it better... At the moment, the script exports all the notebook i tell him or all of them. That is fine. The only thing I wold like to add is: Tell the script to compare if the notebook modification date if newer than the existing exported file on the disk. For date i need to get the modification of the notebook in question and compare it with the date of the already exported file on disk. That would be no problem, if i would not be stuck on the that d..... modification date. set modification to "whatever" does not work - or i do something wrong - which is absolutely possible! Heeelp! Thanks Here the script (starting version) - if i do not get over this - i cannot continue... with timeout of (30 * 60) seconds tell application "Evernote" activate display dialog "Evernote running" delay 2 set notebookName to ("!Inbox") display dialog notebookName delay 2 set datestamp to (modification date) display dialog datestamp delay 4 end tell end timeout Link to comment
bswiss56 8 Posted February 20, 2016 Author Share Posted February 20, 2016 Here an update of the script... still not working... with timeout of (30 * 60) seconds tell application "Evernote" activate display dialog "Evernote running" delay 2 set notebookName to ("!Inbox") display dialog notebookName delay 2 set modDate to modification date of notebookName display dialog modDate delay 4 end tell end timeout Link to comment
bswiss56 8 Posted February 20, 2016 Author Share Posted February 20, 2016 error message error "Can’t get modification date of \"!Inbox\"." number -1728 from «class EVmm» of "!Inbox" Link to comment
Level 5* JMichaelTX 4,115 Posted February 21, 2016 Level 5* Share Posted February 21, 2016 16 hours ago, bswiss56 said: For date i need to get the modification of the notebook in question I don't think this is possible because Evernote does not expose a "modified date" property for Notebooks. I also don't see this info available in the UI. From the Evernote SDEF: Quote notebook n : A notebook. elements contains notes; contained by application. propertiesname (text) : The notebook's name.notebook type (synchronized/published/local only/business, r/o) : The notebook's type.default (boolean, r/o) : Indicates if this is the 'default' notebook for the account. The best you can do is to find the most recent modified Note in a Notebook, and use its "modified date". This is not trivial because Evernote does NOT offer a "sort by" AppleScript command. Here are some references that might help: How to set view and sort order from Applescript Sorting a notebook for AppleScript If you are able to write a script to do this, please post it here. I'm sure it would be very helpful to a lot of your fellow Evernote users. Link to comment
Level 5* JMichaelTX 4,115 Posted February 21, 2016 Level 5* Share Posted February 21, 2016 3 hours ago, JMichaelTX said: The best you can do is to find the most recent modified Note in a Notebook, and use its "modified date". This is not trivial because Evernote does NOT offer a "sort by" AppleScript command @bswiss56: I was able to work out this quick-and-dirty script, just to server as proof of concept. It seems to work, but it might be slow for large numbers of Notes. It took 17.2 seconds for 2,563 notes. But maybe it gives you a place to start. Note that it requires the "ASObjC Runner" app, which is a free app found at:ASObjC Runner Vanilla Mode -- download link is at bottom of that page. set cmdStr to "perl -e 'use Time::HiRes qw(time); print time'" set timeStart to do shell script cmdStr set noteRecList to {} --- GET LIST OF NOTES FROM EVERNOTE --- tell application "Evernote" --set selNotes to selection -- OR -- set selNotes to (find notes "notebook:.Inbox") set numNotes to count of selNotes log "Num of Notes: " & numNotes display notification "Number of Notes: " & numNotes set noteIndex to 0 repeat with oNote in selNotes set noteIndex to noteIndex + 1 set noteTitleStr to title of oNote set creationDate to creation date of oNote set modificationDate to modification date of oNote --- ADD TO LIST OF RECORDS SO NOTES CAN BE SORTED ON DATE --- copy {index:noteIndex, modDate:modificationDate, noteTitle:noteTitleStr} to the end of noteRecList --noteObj:oNote, --> when I included the oNote object, the rearrange records got error. end repeat end tell set noteRec to item 1 of noteRecList log "~~~ INFO OF FIRST NOTE PRIOR TO SORT ~~~" log modDate of noteRec log noteTitle of noteRec --- SORT THE NOTE RECORD LIST --- tell application "ASObjC Runner" set sortedList to rearrange records noteRecList by keys "modDate" without ascending orders end tell log " ~~~~ AFTER SORT ~~~~ " --- GET THE 1st NOTE IN THE SORTED LIST, WHICH SHOULD BE THE MOST RECENT --- set noteRec to item 1 of sortedList log modDate of noteRec log noteTitle of noteRec log index of noteRec set noteIndex to (index of noteRec) --- NOW GET THE SAME NOTE OBJECT FROM THE EVERNOTE NOTE LIST --- tell application "Evernote" set oNote to (item noteIndex of selNotes) log "~~~ CONFIRM SELECTION OF NOTE OBJECT ~~~" log (modification date of oNote as string) log (title of oNote as string) end tell set timeStop to do shell script cmdStr set executionTime to (round ((timeStop - timeStart) * 1000)) / 1000.0 log "Execution Time: " & executionTime & " sec" Link to comment
Level 5* DTLow 5,735 Posted February 21, 2016 Level 5* Share Posted February 21, 2016 17 hours ago, JMichaelTX said: I was able to work out this quick-and-dirty script, just to server as proof of concept. I did the same thing - a lot dirtier; runs in under a minute for 6000+ notes I was impressed on how fast it ran, and didn't have a problem with that size of list tell application "Evernote"set notebook1 to "File Cabinet"set DateList to (creation date of every note in notebooknotebook1 as list)set minimum to item 1 of DateListset maximum to item 1 of DateListrepeat with noteDate in DateListif noteDate > maximum then set maximum to noteDateif noteDate < minimum then set minimum to noteDateend repeatdisplay dialog minimum as stringdisplay dialog maximum as string end tell Link to comment
Level 5* JMichaelTX 4,115 Posted February 21, 2016 Level 5* Share Posted February 21, 2016 9 minutes ago, DTLow said: I did the same thing - a lot dirtyer; runs in under a minute for 6000+ notes That's not bad if all you want is the min or max date. But if you want the Note (or Notes) that goes with that min/max, then it is much more complicated. My script would take about 40 sec for 6000 notes. Link to comment
bswiss56 8 Posted February 21, 2016 Author Share Posted February 21, 2016 Hey guys! It works! Thank you soo much! Link to comment
Level 5* JMichaelTX 4,115 Posted February 23, 2016 Level 5* Share Posted February 23, 2016 @bswiss56: For a very, very fast script, see this: Evernote Mac (EN Mac) Get and Sort Large List of Notes by Note Property using AppleScript and ASObjC It retrieved and sorted 4,000+ notes in less than 0.8 sec. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.