KeyRoutines
StepFreefile.writeText

Write or create a text file automatically on Windows

Write text file saves text into a file. It can replace whatever the file held, or only write when the file doesn't exist yet so nothing is ever overwritten.

How it works

  • Choose the file, the text and the mode: replace, or create only when missing.
  • The folder is created if needed, and text is saved as UTF-8.
  • The new contents appear only once fully written, so other apps never see half a file.
  • A brand-new file is recorded so Undo file moves can remove it; replaced contents aren't brought back.

Routines that use it

Daily note from a template

Each morning, create a note named with today's date only if it doesn't exist, then open it with Open file or folder.

Save what's playing

Get now playing, then write the track title to a text file that a stream overlay displays.

Keep the clipboard

On a Hotkey, write the result of Get clipboard into a scratch file.

Settings

SettingWhat it does
PathThe text file.
TextWhat to write.
ModeReplace the file, or write only when it doesn't exist yet.

Good to know

  • Undo file moves doesn't restore what a file held before it was replaced.

Questions

How do I create a text file without overwriting an existing one?
Set Write text file to "write only when it doesn't exist yet". If the file is already there, it is left untouched.
What's the difference between Write text file and Add text to file?
Write text file replaces the contents, while Add text to file adds to the end. Pick Add text to file for logs.

Pairs well with

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.