Forked from arthurlockman/gist:a5e7b3a98d722f706793
Created
October 12, 2015 14:40
-
-
Save rkoopmann/926e4225f149760d06f4 to your computer and use it in GitHub Desktop.
HTML to Notes 1.1
This file contains 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
#!/usr/local/bin/zsh | |
osascript \ | |
-e 'tell application "Notes" to activate' \ | |
-e 'delay 1' | |
for f in $@*.html | |
do | |
filename=$(basename "$f") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
if [ "$filename" != "index" ] | |
then | |
echo "$filename" | tr _ - | pbcopy | |
osascript \ | |
-e 'tell application "Notes"' \ | |
-e 'activate' \ | |
-e 'tell application "System Events" to tell process "Notes"' \ | |
-e 'click menu item "New Note" of menu 1 of menu bar item "File" of menu bar 1' \ | |
-e 'keystroke "v" using command down' \ | |
-e 'keystroke "a" using command down' \ | |
-e 'keystroke "t" using {command down, shift down}' \ | |
-e 'key code 125' \ | |
-e 'end tell' \ | |
-e 'end tell' | |
textutil -format html -convert rtf -stdout "$f" | pbcopy | |
osascript \ | |
-e 'tell application "Notes"' \ | |
-e 'activate' \ | |
-e 'tell application "System Events" to tell process "Notes"' \ | |
-e 'keystroke return' \ | |
-e 'keystroke "v" using command down' \ | |
-e 'end tell' \ | |
-e 'end tell' | |
resources="${f%.html}.resources" | |
if [ -d $resources ] | |
then | |
for h in $resources/* | |
do | |
osascript \ | |
-e 'on run args' \ | |
-e 'set the clipboard to POSIX file (first item of args)' \ | |
-e end \ | |
"$h" | |
osascript \ | |
-e 'tell application "Notes"' \ | |
-e 'activate' \ | |
-e 'tell application "System Events" to tell process "Notes"' \ | |
-e 'keystroke return' \ | |
-e 'keystroke "v" using command down' \ | |
-e 'end tell' \ | |
-e 'end tell' | |
done | |
fi | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment