forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch-note-by-name.applescript
executable file
·65 lines (47 loc) · 1.57 KB
/
search-note-by-name.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Search Note By Name
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/notes.png
# @raycast.argument1 { "type": "text", "placeholder": "Exact Note Name or a Substring" }
# @raycast.packageName Notes
# Documentation:
# @raycast.description This script searches for a note, given its exact name, or a substring, the search does not consider case
# if two notes or more have the same given substring the script will always show the first one
# @raycast.author Ayoub Gharbi
# @raycast.authorURL github.com/ayoub-g
on run argv
set note_to_search to (item 1 of argv)
tell application "Notes"
activate
set search_complete to false
set note_found to false
set folder_index to 1
set folders_count to (count of folders)
repeat while search_complete is false
set note_index to 1
set end_list to false
set leave_list to false
set note_names to (name of notes of folder folder_index)
repeat while leave_list is false
set note_name to item note_index of note_names
if note_to_search is in note_name then
show note note_name
set note_found to true
set search_complete to true
end if
set note_index to (note_index + 1)
if note_index > (count of note_names) then
set end_list to true
end if
set leave_list to end_list or note_found
end repeat
set folder_index to (folder_index + 1)
if folder_index > folders_count then
set search_complete to true
end if
end repeat
end tell
end run