You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"description": "This script creates a menu item and a button that searches through all notes and removes links to all notes (Markdown files) that no longer exist, also known as dead note links."
10
-
}
1
+
{
2
+
"name": "RemoveDeadNoteLink",
3
+
"identifier": "removedeadnotelink",
4
+
"script": "removedeadnotelink.qml",
5
+
"authors": ["@Glin76"],
6
+
"platforms": ["linux", "macos", "windows"],
7
+
"version": "0.0.1",
8
+
"minAppVersion": "25.6.1",
9
+
"description": "This script creates a menu item and a button that searches through all notes and removes links to all notes (Markdown files) that no longer exist, also known as dead note links."
Copy file name to clipboardExpand all lines: removedeadnotelink/removedeadnotelink.qml
+38-37Lines changed: 38 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -3,51 +3,52 @@ import QtQml 2.0
3
3
/**
4
4
* This script creates a menu item and a button that search in all notes and remove links to note (MD file) no longer existing (aka dead note-link)
5
5
*/
6
-
7
-
QtObject {
8
6
7
+
QtObject {
9
8
functioncustomActionInvoked(identifier) {
10
9
switch (identifier) {
11
-
case"RemoveDeadNoteLink":
12
-
var dialogText ="";
13
-
var reLink =RegExp("\\[.*\\]\\(.*\\.md\\)", "g"); // RegExp to find links : "[***](***.md)"
14
-
script.fetchNoteIdsByNoteTextPart("").forEach(function (noteId){ // Loop for all notes
15
-
var linkText ="";
16
-
var note =script.fetchNoteById(noteId);
17
-
var newNoteText =note.noteText;
18
-
var LinkFound =reLink.exec(note.noteText);
19
-
while (LinkFound !=null){ // Loop for all links in the note
20
-
var LinkNoteName =LinkFound.toString().replace(RegExp(".*\\(", "").exec(LinkFound),"") // RegExp to find the name of the link : from start of the link to "(", and then removed from the string
21
-
LinkNoteName =LinkNoteName.toString().replace(RegExp(".*\\/", "").exec(LinkNoteName),"") // RegExp to find the relative path : from start to the last"/", and then removed from the string
22
-
LinkNoteName =LinkNoteName.replace(")",""); // removing last ")" of the link
23
-
while (LinkNoteName.search("%20") >-1) {
24
-
LinkNoteName =LinkNoteName.replace("%20", ""); // replacing all the %20 by space in the filename
25
-
}
26
-
if (script.fetchNoteByFileName(LinkNoteName).id==0) { // Does a note exist with that filename
27
-
newNoteText =newNoteText.replace(LinkFound, ""); // removing the link in the future NoteText
28
-
linkText +="\n - "+LinkFound;
29
-
}
30
-
LinkFound =reLink.exec(note.noteText);
10
+
case"RemoveDeadNoteLink":
11
+
var dialogText ="";
12
+
var reLink =RegExp("\\[.*\\]\\(.*\\.md\\)", "g"); // RegExp to find links : "[***](***.md)"
var LinkNoteName =LinkFound.toString().replace(RegExp(".*\\(", "").exec(LinkFound), ""); // RegExp to find the name of the link : from start of the link to "(", and then removed from the string
22
+
LinkNoteName =LinkNoteName.toString().replace(RegExp(".*\\/", "").exec(LinkNoteName), ""); // RegExp to find the relative path : from start to the last"/", and then removed from the string
23
+
LinkNoteName =LinkNoteName.replace(")", ""); // removing last ")" of the link
24
+
while (LinkNoteName.search("%20") >-1) {
25
+
LinkNoteName =LinkNoteName.replace("%20", ""); // replacing all the %20 by space in the filename
0 commit comments