Stubborn URI %20 in ScriptUI Dialog Button Text Field
When the script is run with a single open and saved doc, the doc is closed and its path and name are used to populate the following scriptUI dialog:

However, when running the "Select Input File" button manually, the Name: field is incorrectly using URI encoded word space %20 characters. Although the file saves correctly, this is confusing for users:

I have spent hours trying to fix this up, without any success. I have tried various decodeURI() and decodeURIComponent() and regular expressions and split/join in fruitless attempts to sanitise the result.
I'm sure it's a newb error, my scriptUI is next to zero and I have only made it this far with the help of AI to build the GUI around my existing code. The full code can be found in the following link, I want to keep that topic separate from the bug fixing in this topic, however, I will give credit in the updated code:
Please reply in this topic, thank you in advance!

