Skip to main content
Known Participant
December 8, 2023
Question

filename with special characters is broken

  • December 8, 2023
  • 2 replies
  • 396 views

Hi All,
In Photoshop scripting, the filename with special characters(<>,[], -) is broken and able to save the file using scripting, I tried with the encodeURI method, and it works but the original fileName with special characters has converted into encoded value.

for ex: original filename is "For PLUS+SP – 2.jpg" its broken like "For  PLUS+SP †2" not able to save the file.
if converted into an encoding method, it can save names like
 "For %20PLUS+SP%20%13%E2%80%A02.tif" if i decoded it will come like broken  "For PLUS+SP †2".
 i want to save the file with original filename using script without broken and also handle if any special characters in the filename. is it acheivable?



This topic has been closed for replies.

2 replies

Legend
December 11, 2023

It's not very clear what's wrong with you.

Why are you using encodeURI and decodeURI?

And how did you get from "For PLUS+SP – 2.jpg"

this: "For %20PLUS+SP%20%13%E2%80%A02.tif" ?

 

I get "For%20PLUS+SP%20%E2%80%93%202.jpg".

And it decodes back without problems.

 

If you use characters from UTF8 in a script, then in order for Photoshop to correctly understand that this is UTF8, your file must contain a BOM mark at the beginning to work correctly with these characters.

About BOM read this topic https://community.adobe.com/t5/photoshop-ecosystem-discussions/charset-of-textitem/m-p/9966206

 

 

jane-e
Community Expert
Community Expert
December 11, 2023

@Rocky@ 

 

Filenames are restricted by Windows, not applications. 

https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Name the files in a way that won't cause errors.

 

Jane