Created
June 13, 2023 08:17
-
-
Save asidko/d744db5085e61d181aa957cf4aead274 to your computer and use it in GitHub Desktop.
Raycast script to append custom text to pre-configured Apple Note.
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
#!/usr/bin/osascript | |
# Required parameters: | |
# @raycast.author asidko | |
# @raycast.schemaVersion 1 | |
# @raycast.title Note text to "Worklog" note | |
# @raycast.mode silent | |
# @raycast.packageName Notes | |
# @raycast.description Append text to pre defined note | |
# @raycast.argument1 { "type": "text", "placeholder": "text to append" } | |
# | |
# Optional parameters: | |
# @raycast.icon 📝 | |
# @raycast.needsConfirmation false | |
on run argv | |
-- SET TARGET NOTE NAME HERE <<<<<<<<<<<<< -- | |
set targetNoteName to "Worklog" | |
-- | |
set newText to item 1 of argv | |
set currentDateText to formatDate() | |
tell application "Notes" | |
set targetNote to note named targetNoteName | |
if targetNote is not missing value then | |
set noteBody to body of targetNote | |
if noteBody contains currentDateText then | |
set updatedBody to noteBody & return & newText | |
else | |
set updatedBody to noteBody & return & "<p>" & currentDateText & "</p>" & return & newText | |
end if | |
set body of targetNote to updatedBody | |
else | |
display dialog "Note not found." | |
end if | |
end tell | |
end run | |
on formatDate() | |
set currentDate to current date | |
set monthNames to {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} | |
set weekdayNames to {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"} | |
set currentDateText to (day of currentDate as string) & " " & (item (month of currentDate) of monthNames) & ", " & (item (weekday of currentDate) of weekdayNames) | |
return currentDateText | |
end formatDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment