Remove Illegal and Unwanted filename characters from a string with AutoHotkey v1

ReplaceFileNameCharctersWhen programatically creating files, it is easy to have unwanted characters creep into your file names.  I have this function to remove illegal filename characters.  I also remove characters that I just don’t want but are legitimate for a Windows file name.

Auto-Replace Illegal Characters for “dumb” CMS systems (2021)
Auto-Replace Illegal Characters for


Joe Glines

Joe Glines spent 20 years as a corporate data scientist before going all in on automation. He now uses AI to build automation in AutoHotkey, Python and Rust, has made 1,500+ tutorials, and runs the-Automator with a small team that has shipped 450+ time-saving tools.

Comments are closed.