Created
January 11, 2016 21:57
-
-
Save sprig/0e4c3e241ce3e60f9a2e to your computer and use it in GitHub Desktop.
Download entire page for selected notes, from the given URLs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Evernote = Application("Evernote"); | |
try | |
{ | |
var newnotes = []; | |
var note, tags, tl, url, newNote, noteWindow; | |
var before = Evernote.tags.byName("foo"); | |
var error = Evernote.tags.byName("bar"); | |
var after = Evernote.tags.byName("baz"); | |
var selection = Evernote.selection(); | |
var len = selection.length; | |
var perc = Math.floor(len/100); | |
console.log(len, " notes selected"); | |
var i,j,k; | |
for (i = 0; i < len; i++) { | |
note = selection[i]; | |
tags = note.tags(); | |
tl = tags.length; | |
for (j = 0; j < tl; j++) {tags[j] = tags[j].name()}; | |
// console.log(tags); | |
if (tags.indexOf(after.name()) >= 0) { | |
continue; | |
} | |
if (i % perc >= 0) { | |
console.log(i / perc, "% complete!"); | |
} | |
before.assign({to: note}); | |
url = note.sourceURL(); | |
if ( url ) { | |
console.log(url); | |
newNote = {fromUrl: url, title:note.title(), notebook:'pinboard', tags:tags, created:note.creationDate()}; | |
newnotes.push(newNote); | |
newNote = Evernote.createNote(newNote) | |
noteWindow = Evernote.openNoteWindow({with: newNote}); | |
noteWindow.close() | |
try { | |
after.assign({to: note}); | |
} | |
catch (e) { | |
console.log(e, JSON.stringify(e)); | |
} | |
} | |
else { | |
console.log("NO URL"); | |
error.assign({to: note}); | |
after.assign({to: note}); | |
continue; | |
} | |
} | |
} | |
catch (e) { | |
console.log(e, JSON.stringify(e)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment