How to Automatically Generate a Daily log.txt File of New Files on macOS?

I want to automatically create a log.txt file on my Mac desktop every day that lists the names of all files created that day. What’s the best way to achieve this on macOS (10.14.3)?

If you want to automatically generate a file named log.txt on your desktop every day that records the names of all newly created files for that day, you can create a script that uses the find command to locate today’s new files and write the results to a log file on your desktop:

#! /bin/bash

LOG_FILE=~/Desktop/log_$(date +%Y-%m-%d).txt
SEARCH_DIR=~

# Find files created since the start of today and save to log file
find "$SEARCH_DIR" -type f -newermt "$(date +%Y-%m-%d)"  > "$LOG_FILE"

Save this script as ~/daily_new_files_logger.sh and make it executable by running:
chmod +x ~/daily_new_files_logger.sh

Then, you can use a LaunchAgent to automatically run this script every day at a specific time (for example, 8 AM):

launchctl load ~/Library/LaunchAgents/com.user.dailylogger.plist