These short bits of awk code are doing a fair bit. I'm not sure there's a simpler, trivial solution; if it works well I'd be tempted to leave well enough alone!
But without seeing the intent it's difficult to guess
If these files are temporary files, you should be saving them in names like /tmp/$$-timebased.log to protect them from being stomped on by multiple instances of the program.