1

I found this question about the possibility to exchange windows paths with mac users and vice versa.

How to translate between Windows and Mac -style file locations?

It's working great for me, but for some reason the finder won't open paths with special characters in it. For example ä, ö, ü (which are common in germany).

I thought they are converted or something. So I removed the tell application part and replaced it with return mylocation to see whats happening. The returned path is the correct one and also special characters are in it.

Why does the finder not open it? Is there any workaround for this?

I paste the code here, so we talk about the same thing without confusion:

on searchReplace(theText, SearchString, ReplaceString)
    set OldDelims to AppleScript's text item delimiters
    set AppleScript's text item delimiters to SearchString
    set newText to text items of theText
    set AppleScript's text item delimiters to ReplaceString
    set newText to newText as text
    set AppleScript's text item delimiters to OldDelims
    return newText
end searchReplace

on run {input, parameters}
    
    set myClip to the input
    set mylocation to searchReplace(myClip, "<", "")
    set mylocation to searchReplace(mylocation, ">.", "")
    set mylocation to searchReplace(mylocation, ">", "")
    set mylocation to searchReplace(mylocation, "\\", "/")
    set mylocation to "smb:" & mylocation
    set mylocation to searchReplace(mylocation, " ", "%20")
    
    
    tell application "Finder"
        open location mylocation
    end tell
    
    # after setting the location, set Finder to topmost, or delete this section if you dont want that.
    tell application "Finder"
        activate
    end tell
    
    
    return input
end run
5
  • What is the input to the action? Note that input is typically a list, and open location is not from Finder.
    – red_menace
    Commented May 20, 2021 at 14:45
  • @red_menace The input is a windows type path (highlighted as text). So for example something like this \\Servername\Folder 1\Folder 2\Folder with ä as special character When I use return mylocation as described above, the path would be translated into smb://Servername/Folder%201/Folder%202/Folder%20with%20ä%20as%20special%20character
    – jona
    Commented May 21, 2021 at 9:56
  • The special character is in the output, but the finder won't open it. Any other path without a special character like this works fine.
    – jona
    Commented May 21, 2021 at 10:03
  • I don’t have a server to test with, but open location opens files and URLs with umlauts just fine on my Big Sur machine. I was asking what is being used to get the input to the AppleScript action - if it is a Finder action, you might try using POSIX paths, since open location is not from the Finder.
    – red_menace
    Commented May 21, 2021 at 14:39
  • @red_menace I'm pretty new to this, but I think I understand what you mean. It's a service that I add. So wherever I am I can highlight a windows path, rightclick, services and select my script.
    – jona
    Commented May 22, 2021 at 15:17

1 Answer 1

0

I fixed it by decoding the umlauts like this:

considering case
    set mylocation to searchReplace(mylocation, "Ä", "%C3%84")
    set mylocation to searchReplace(mylocation, "ä", "%C3%A4")
    set mylocation to searchReplace(mylocation, "Ö", "%C3%96")
    set mylocation to searchReplace(mylocation, "ö", "%C3%B6")
    set mylocation to searchReplace(mylocation, "Ü", "%C3%9C")
    set mylocation to searchReplace(mylocation, "ü", "%C3%BC")
    set mylocation to searchReplace(mylocation, "ß", "%C3%9F")
    set mylocation to searchReplace(mylocation, "ẞ", "%E1%BA%9E")
end considering

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .