Action

Append to Draft with Timestamp – Effortless Log Entries

Posted by ap3, Last update 11 days ago

This action appends your current draft’s content to a designated destination draft, with a bullet point and a timestamp that includes the date, time, and timezone.

Ideal for maintaining running logs or tracking ideas with precise time records. Just replace the placeholder UUID with your target draft’s UUID, and you’re set!

Features:
- Appends your draft content as a bullet point with a custom-formatted timestamp.
- Fully customizable date and time format.
- Seamlessly updates your chosen destination draft.

Scratchpad Usage:
Inspired by Richard Feynman’s note-taking method, this action is perfect for maintaining topic-based scratchpads. Use it to create ongoing logs on specific topics, allowing structured, time-stamped notes to accumulate over time. It’s excellent for learning or tracking long-term projects, where continuous addition of new insights or ideas to the same draft is required.

Instructions:
1. Replace the placeholder UUID in the script with the UUID of the destination draft where you want the content appended.
2. Run the action to automatically append the current draft’s content to the destination draft.
3. Optionally, customize the timestamp format to suit your preferences.

Effortlessly track logs, ideas, and ongoing notes—all within Drafts!

Examples:
1. Keep a personal journal with time-stamped entries for each new thought or reflection.
2. Create a learning log to capture new insights and study notes on a specific subject.
3. Track book reading notes, appending each new insight or quote with a timestamp.
4. Maintain a workout log, adding each day’s activity as a bullet with the exact time.
5. Use it as a daily habit tracker, appending completed habits with the exact time logged.
6. Keep a running log of customer feedback, appending notes to a central feedback draft.
7. Record brainstorming ideas in a time-stamped format for future review.

Steps

  • script

    let f = () => {
        // Replace [DESTINATION FILE UUID] with the UUID of the draft you want to append to.
        // To find the UUID, open the draft in Drafts, go to the "Info" panel, and copy the UUID.
        let uuid = "[DESTINATION FILE UUID]"; 
    
        // Locate the draft using the UUID provided above.
        let d = Draft.find(uuid);
        
        // If the draft cannot be found, cancel the action.
        if (!d) {
            return false;
        }
        
        // Get the current date and time for the timestamp.
        let now = new Date();
        
        // Format the date and time string. This includes the weekday, date, time, and timezone (e.g., 'Monday, September 5, 2024, 3:45 PM PDT').
        let dateTimeString = now.toLocaleString('en-US', { 
            weekday: 'long', 
            year: 'numeric', 
            month: 'long', 
            day: 'numeric',
            hour: 'numeric', 
            minute: '2-digit',
            timeZoneName: 'short'
        });
        
        // Format the new content. This appends the current draft's content as a bullet point, followed by a timestamp in square brackets.
        // Example output: 
        // - Existing content here [Monday, September 5, 2024, 3:45 PM PDT]
        let formattedContent = `\n\n- ${draft.content} [${dateTimeString}]`;
        
        // Add the formatted content to the existing draft.
        d.content = d.content + formattedContent;
        
        // Save the changes to the draft.
        d.update();
        
        return true;    
    };
    
    // If the function fails (e.g., the draft is not found), cancel the action.
    if (!f()) {
        context.cancel();
    }

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.