Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rkoopmann/926e4225f149760d06f4 to your computer and use it in GitHub Desktop.
Save rkoopmann/926e4225f149760d06f4 to your computer and use it in GitHub Desktop.
HTML to Notes 1.1
#!/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