Photoshop can't open files with UTF-8 codes in name via AppleScript

  • 2
  • Problem
  • Updated 5 months ago
  • (Edited)
If a file contains UTF-8 codes in its name, an error occurs on attempt to open the file in Photoshop via AppleScript.

Steps to reproduce:

-Name any image with the following name:
Ch%C3%A2teauvieux_10_Peney-Dessus_.jpg 

The name contains the "â" character encoded as %C3%A2

-Run the following AppleScript script:

set inFile to choose file with prompt "Select file"
tell application "Adobe Photoshop CC 2018"
open alias (inFile as string) showing dialogs never
end tell

-Select the file with the above name

Photoshop will return the following error:
error "Adobe Photoshop CC 2018 got an error: File some object wasn’t found." number -43

Photoshop CC 2018 19.1.2
macOS 10.13.4

Hopefully it can be fixed!

Thanks a lot,
Leo
Photo of Leo Revzin

Leo Revzin

  • 4 Posts
  • 0 Reply Likes

Posted 5 months ago

  • 2
Photo of Michael Konrad

Michael Konrad

  • 1 Post
  • 0 Reply Likes
I encounted the same error with Adobe Photoshop CC 2018 on macOS 10.11.6
Photo of Mika Kupari

Mika Kupari

  • 11 Posts
  • 2 Reply Likes
You are trying to open a file with URL encoded name. You might find some tips from this stackoverflow thread.

It's been a while since I did anything with appleScript, so all I can do is wish you good luck with your task in hand.

-Mika
Photo of Leo Revzin

Leo Revzin

  • 4 Posts
  • 0 Reply Likes
Thanks Mika.

Interesting info, but the stackoverflow thread deals with a slightly different case, plus it was a few years ago so I don't know if that issue is still around.

The problem I describe seems to be a strictly Photoshop issue. Other apps such as Finder and InDesign open files with UTF codes with no problems.

Thanks again,
Leo 
(Edited)
Photo of Mika Kupari

Mika Kupari

  • 11 Posts
  • 2 Reply Likes
Hi Leo,
I live in Finland, so I see å, ä, ö letters in a lot of filenames daily. I don't have any problem opening them, even with your script.

But, when I change a filename to something that has URL encoding in it, namely your %C3%A2, I get your error.

I did a little bit of testing.

Test 1:Two files: broken_â.jpg and broken_ä.jpg; these are filenames with UTF-8.
I used your script to open them in PS 2018 - no problems, both open straight up. 

Test 2:
Two files: broken_%C3%A2.jpg and broken_%C3%A4.jpg; these are URL encoded filenames. Both end up with "Adobe Photoshop CC 2018 got an error: FIle some object wasn't found." number -43
Test 3:
One InDesign file: Broken_%C3%A2.indd. Modified the script to open the file in InDesign. InDesign can open the file using the script. 

Test 4:
Modified the script to open a selected file in Illustrator. Both UTF-8 and URL encoded JPG files open using the script.

So you are right, there seems to be a bug in Photoshop.

-Mika
Photo of Leo Revzin

Leo Revzin

  • 4 Posts
  • 0 Reply Likes
Mika, thanks for running additional tests!

That indeed confirms there's a bug in Photoshop.

Leo
Photo of David Converse

David Converse

  • 441 Posts
  • 128 Reply Likes
The whole idea of Unicode is that you just use the character. Try doing that, I believe that in High Sierra (and well before) everything should be fully Unicode-compliant.
Photo of Leo Revzin

Leo Revzin

  • 4 Posts
  • 0 Reply Likes
Thanks David,

Yes, I understand the idea of Unicode - but that's not the point.

The situation is the following: a customer who uses my software already had tons of images with UTF-encoded characters. The images are linked to InDesign. How they ended up with those names I don't know - but that's what they have.

I agree that it's better to have the original characters, but the name with UTF codes is still a legitimate file name. Other programs such as Finder and InDesign can open such files via AppleScript with no issues.

Therefore, it seems to be specifically Photoshop bug. Which causes unnecessary problems to both users and developers That's why I hope it can be addressed.

Leo