Autocheck note

What I’m trying to do

I’m trying to set one (to do) check for changes in today’s note. If they are - copie them for to do.

Things I have tried

I’m create a macro that writing the same line in both files, but I need to write to it twice. More than that, it is not set checkers to the same. So I think that I need something that would copie text from one note to another then it’s going out of focus. But l don’t know how. Pls help!

2 Likes

Or maybe it should be a command that would be launched on exit from one of note. Not on-line update.

The first option is to use the text transporter plugin and the second option is to create a macro and create a capture choice 1 and capture choice 2 and enable the task option in both and the daily note path in capture choice 1 and to-do file path in capture choice 2 and then do something similar in capture format

capture choice 1

{{value:Enter the task}}

capture choice 2

{{value:Enter the task}}

By duplicating variables, you don’t have to rewrite the task again.

1 Like

You can make a command for it, install the buttons plugin and then add something like this

```button
type command
name Update the filename
action Quickadd: (the name of the macro)
color default
class *[data-mode='source'] .view-action:first-child {     background-color: orange; } *[data-mode='preview'] .view-action:first-child {     background-color: yellow; }
1 Like

Now I combined the first idea with text transporter module and third, with button. I made button in today daily note. It’s send selection to to-do.
And button in to-do. It’s send selection to daily.
That’s close to my beginning idea, but if I change something in to do, I wanna it’s to be updated in daily note. It may be not automatic - just command to replace block of daily with content of to do.

You can use this script to make it more automated

<%*
async function deleteLinesContainingWord() {
    const filePath = "path/to/your/note.md"; // Path to the specified file
    const noteFile = this.app.vault.getAbstractFileByPath(filePath); // Get the file using the path
    if (!noteFile) return; // If the file is not found

    // Prompt the user for the word
    const word = await tp.system.prompt("Enter the task");

    if (!word) return; // If no word is entered

    // Read the content of the specified file
    let text = await this.app.vault.read(noteFile);

    // Split the text into lines
    let lines = text.split('\n');

    // Filter out lines that do not contain the specified word or the script itself
    let filteredLines = lines.filter(line => !line.includes(word) && !line.includes("deleteLinesContainingWord"));

    // Reassemble the text after filtering
    let newText = filteredLines.join('\n');

    // Write the new text to the file
    await this.app.vault.modify(noteFile, newText);
}

// Call the function
deleteLinesContainingWord();
%>

As you can copy the script into two templates. In the first template, you can put the to do note path in the previous script , in the second template we can make this edit in the script

 const dailyNote = await tp.system.prompt("Enter the Daily note")
 const filePath = `path/to/your/daily/notes/${dailyNote}.md`; // Path to the specified file

The final script will be

<%*
async function deleteLinesContainingWord() {
    const dailyNote = await tp.system.prompt("Enter the Daily note")
    const filePath = `daily/notes/path/${dailyNote}.md`; // Path to the specified file
    const noteFile = this.app.vault.getAbstractFileByPath(filePath); // Get the file using the path
    if (!noteFile) return; // If the file is not found

    // Prompt the user for the word
    const word = await tp.system.prompt("Enter the task");

    if (!word) return; // If no word is entered

    // Read the content of the specified file
    let text = await this.app.vault.read(noteFile);

    // Split the text into lines
    let lines = text.split('\n');

    // Filter out lines that do not contain the specified word or the script itself
    let filteredLines = lines.filter(line => !line.includes(word) && !line.includes("deleteLinesContainingWord"));

    // Reassemble the text after filtering
    let newText = filteredLines.join('\n');

    // Write the new text to the file
    await this.app.vault.modify(noteFile, newText);
}

// Call the function
deleteLinesContainingWord();
%>

You can create a command for them from the templater settings and create a button for each of them using this button

```button
type command
name Delete the task from daily note
action Templater: Insert (the final script path after making the command).md
color default
class *[data-mode='source'] .view-action:first-child {     background-color: orange; } *[data-mode='preview'] .view-action:first-child {     background-color: yellow; }
```button
type command
name Delete the task from to-do 
action Templater: Insert (the first script path after making the command).md
color default
class *[data-mode='source'] .view-action:first-child {     background-color: orange; } *[data-mode='preview'] .view-action:first-child {     background-color: yellow; }

With this script, you can delete the task from the to do note if you want to make an edit and resubmit it again after making the edit using the text transporter plugin and the other way around , the script will ask you about the content of the task, go to the note and delete the task from the note , but when you make an edit from to do note to the daily note, you will be asked for the name of the daily note.

Oh, damn. That’s hard. Ok. There should I write this? Just put in note?

1 Like

All you have to do is :

  1. put the scripts (the first one and the final script) in two notes (templates)
  2. put them in a specific folder
  3. add the to do path in the first script in my previous message (must be inside a note)
  4. add the daily notes path in the final script (must be inside a note)
  5. copy their path
  6. create commands for them in templater settings (by the templates paths)
  7. put the path of the templates, each one in the appropriate button.

I hope this explanation is simple.

1 Like

I make everything just like you said but button delete task in to do, but not in daily(

1 Like

Put the delete task from to-do button in your daily note template and put the delete task from daily note button in to-do note so that when you want to make an edit, you delete the old task and resubmit it again in a more automated way than before.

I think this is the closest thing to what you’re looking for.

That’s remove text only in to-do.

May be there is another way. I want this cause I have a canvas that contains to-do. Cause I didn’t find a way to insert a dynamic link for today note - I made to-do note. Representation of actual to-da in canvas is final task.

If you mean:

That the first script only deletes the task from the to-do note and the final script not working ,then you must have made a mistake in the steps that I have written for you, because the final script will not find the daily note unless there is an incorrect path for your daily notes that you entered in the body of the script or you made a mistake in something else, and this is for two reasons, the first is that the two scripts are basically the same, but the difference lies in that the final script only asks you for the day that contains the task that you want to delete, this is the difference, and the second is that I tried the solution before I sent it and it worked well as shown here :slightly_smiling_face: :
Untitled design

That the solution is fully functional but you want to delete the task from both notes
(meaning you want to merge the two scripts together),

then this script will do that :

<%*
async function deleteLinesContainingWord() {
    // Phase 1: Delete the task from the to-do note
    const initialFilePath = "path/to/your/note.md"; // Path to the to-do file
    const initialNoteFile = this.app.vault.getAbstractFileByPath(initialFilePath); // Get the file using the path
    if (!initialNoteFile) {
        new Notice("The to-do note not found.");
        return; // If the file is not found
    }

    // Prompt for the task to delete
    const word = await tp.system.prompt("Enter the task to delete");

    if (!word) {
        new Notice("No Task entered.");
        return; // If no word is entered
    }

    // Read the content of the specified file
    let initialText = await this.app.vault.read(initialNoteFile);

    // Split the text into lines
    let initialLines = initialText.split('\n');

    // Filter out lines that do not contain the task 
    let initialFilteredLines = initialLines.filter(line => !line.includes(word) && !line.includes("deleteLinesContainingWord"));

    if (initialFilteredLines.length === initialLines.length) {
        new Notice(`This task isn't in to-do note.`);
    }

    // Reassemble the text after filtering
    let initialNewText = initialFilteredLines.join('\n');

    // Write the new text to the file
    await this.app.vault.modify(initialNoteFile, initialNewText);

    // Phase 2: Delete the task from the daily note
    const dailyNote = await tp.system.prompt("Enter the Daily note");
    const dailyFilePath = `daily/notes/path/${dailyNote}.md`; // Path to the daily note
    const dailyNoteFile = this.app.vault.getAbstractFileByPath(dailyFilePath); // Get the file using the path
    if (!dailyNoteFile) {
        new Notice("Daily note not found or there is an incorrect path inside the script.");
        return; // If the file is not found
    }

    // Read the content of the daily file
    let dailyText = await this.app.vault.read(dailyNoteFile);

    // Split the text into lines
    let dailyLines = dailyText.split('\n');

    // Filter out lines that do not contain the task
    let dailyFilteredLines = dailyLines.filter(line => !line.includes(word) && !line.includes("deleteLinesContainingWord"));

    if (dailyFilteredLines.length === dailyLines.length) {
        new Notice(`This task isn't in the entered daily note.`);
    }

    // Reassemble the text after filtering
    let dailyNewText = dailyFilteredLines.join('\n');

    // Write the new text to the file
    await this.app.vault.modify(dailyNoteFile, dailyNewText);
}

// Call the function
deleteLinesContainingWord();
%>

Do the same steps with the previous script and put it in a button and this will fulfil your request.