Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Stubborn URI %20 in ScriptUI Dialog Button Text Field

Community Expert ,
Oct 06, 2024 Oct 06, 2024

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:

 

correct.png

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:

 

incorrect.png

 

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:

 

https://community.adobe.com/t5/photoshop-ecosystem-ideas/new-feature-request-layers-to-pdf/idc-p/149...

 

Please reply in this topic, thank you in advance!

 

TOPICS
Actions and scripting
314
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 07, 2024 Oct 07, 2024

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
...
Translate
Adobe
LEGEND ,
Oct 07, 2024 Oct 07, 2024

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, "");

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024
LATEST

@Lumigraphics 

 

Thank you, I made a variable from the file object and that resolved the issue!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines