Barand, thanks for taking the time to reply to my question- but after spending yet more hours trying to get this working I am giving up on this solution for now, and having a look at using python to fix the problem instead. I am not a programmer or web developer, just a retired ham trying to make things work the way I want them to.
I think I can get the errant program to save the files in one directory, then use a python script to rename and move them to the correct directory. Again, I'm no python programmer, but with lots of reading I can usually muddle through. There's quite a bit of python behind my web pages, all of which I wrote myself, and the whole shebang is hosted right here in my radio shack. And like you, I am 75 years young! (and originally from Sheffield, but that was over 50 years ago)
Ken, vk7krj
https://vk7krj.com/index.html