Action

Find incomplete tasks

Posted by Thomas Schoffelen, Last update over 1 year ago

Creates a temporary view of any inbox drafts that have incomplete tasks (e.g. with - [ ]).

Steps

  • script

    let content = "# Incomplete tasks\n";
    
    const drafts = Draft.query("", "inbox")
    
    for (const file of drafts){
    	const lines = file.content.split("\n");
    	let hasAddedTitle = false;
    	for (const line of lines) {
    		if (!line.includes("- [ ] ")) {
    			continue;
    		}
    
    		const title = line.replace("- [ ]", "").trim();
    		if (!title) {
    			continue;
    		}
    
    		if (!hasAddedTitle) {
    			content += `\n## ${file.displayTitle}\n${file.permalink}\n`;
    			hasAddedTitle = true;
    		}
    
    		content += `- [ ] ${title}\n`;
    	}
    }
    
    let d = new Draft();
    d.content = content;
    d.isTrashed = true;
    d.update();
    
    editor.load(d);

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.