Last active
January 15, 2016 16:58
-
-
Save JMichaelTX/f696bb95f6246f546505 to your computer and use it in GitHub Desktop.
[EN] Move a Tag to be a Child of a Parent Tag [JXA] - Evernote Mac, JavaScript for Automation
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
/* | |
⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶ | |
[EN] How to Make Tag a Child Tag of a Parent Tag [JXA] | |
⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶ | |
DATE: Fri, Jan 15, 2016 | |
AUTHOR: JMichaelTX (in most forums) | |
Find any bugs/issues or have suggestions for improvement? | |
Post below, or contact me via PM or at blog.jmichaeltx.com/contact/ | |
REF: | |
⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶⩶ | |
*/ | |
var app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
var ENapp = Application("Evernote"); | |
var tagNameStr | |
var tagParStr | |
var strMsg = "Enter the Tag You Want to Move Under a Parent Tag" | |
var strTitle = "Move Tag" | |
app.beep() | |
var oAns = app.displayDialog(strMsg, | |
{ | |
withTitle: strTitle, | |
withIcon: "caution", | |
defaultAnswer: "" | |
}) | |
tagNameStr = oAns.textReturned | |
strMsg = "Enter the PARENT Tag for Tag " + tagNameStr | |
app.beep() | |
var oAns = app.displayDialog(strMsg, | |
{ | |
withTitle: strTitle, | |
withIcon: "caution", | |
defaultAnswer: "" | |
}) | |
tagParStr = oAns.textReturned | |
var tagObj = ENapp.tags.byName(tagNameStr); | |
var tagParObj = ENapp.tags.byName(tagParStr); | |
if (tagObj.exists()) { | |
if (tagParObj.exists()) { | |
//--- SET THE PARENT TAG --- | |
tagObj.parent = tagParObj | |
console.log('Tag: ' + tagObj.name() + ' Parent: ' + tagObj.parent.name()) | |
app.displayAlert ('SUCCESS! \nTag: ' + tagObj.name() | |
+ ' \n has been moved to a child tag of ' | |
+ '\nParent Tag: ' + tagObj.parent.name() | |
); | |
} else { | |
app.displayAlert('Parent Tag: ' + tagParStr + ' does NOT EXIST') | |
} // END if (tagParObj.exists()) | |
} else { | |
app.displayAlert('Tag: ' + tagNameStr + ' does NOT EXIST') | |
} // END if (tagObj.exists()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JMichaelTX JXA Gists
Because there is so little JavaScript for Automation (JXA) code that is published, I plan to publish as much as I can that will hopefully be of help to others learning JXA.
Much of what I publish will be based on the work of others, and I always try to cite those references in the code header. If I have failed to properly credit your code, please post a comment, and I will correct my Gist.
Your JXA Code
If you have example code you'd like to share, please post a link to your code. After having searched and evaluated various options for posting/sharing code, i have concluded that Github Gists is the best.
Bugs/Issues & Suggestions
If you find any bugs or issues, or have suggestions for improvement, please feel free to post a comment.
For more info, see JavaScript for Automation (JXA) Resources