Hi
there’s an old answer here, probably still applies (approximately, maybe some line numbers are changed)
If you want a solution without code (and with plenty more features), in the context of sending emails or campaigns, have a look at my add-on PowerReplacer, the demo video shows dynamic attachment names.