Copy link to clipboard
Copied
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!
Quit processing the name. Just use File.fullName or File.fsName and put that in your text field as-is.
var baseNameText = filenameGroup.add("edittext", undefined, "");
baseNameText.text = "abc";
Try this snippet (run directly in VSCode) to see the differences:
var myFile = File.openDialog();
Window.alert(myFile.fullName + '\r' + myFile.fsName + '\r' + myFile.name);
Also, its easier to follow if you use this format for your child elements:
filenameGroup.baseName = filenameGroup.add("edittext", u
...
Copy link to clipboard
Copied
Quit processing the name. Just use File.fullName or File.fsName and put that in your text field as-is.
var baseNameText = filenameGroup.add("edittext", undefined, "");
baseNameText.text = "abc";
Try this snippet (run directly in VSCode) to see the differences:
var myFile = File.openDialog();
Window.alert(myFile.fullName + '\r' + myFile.fsName + '\r' + myFile.name);
Also, its easier to follow if you use this format for your child elements:
filenameGroup.baseName = filenameGroup.add("edittext", undefined, "");
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now