You can enter and execute a small script written in the built-in IDC language or any other registered extlang.
Here is the list of built-in functions.
See also:
IDC language overview
Execute script file command
File... submenu commands
How to use notepad.