leopard not happy with space names in my app? or is it something else

Say I have an application called “My Path Tester.app”

I want to use the path of that application to find out where it is located - because I want to use that location for something else.

So I get the path to the application as a string, then replace the application name (“My Path Tester.app”) name with nothing (“”)…so the result should be the path to where the application is.

ie… if the path to my app is →
HD:Applications:myFolder:My Path Tester.app
and I replace the application name “My Path Tester.app” with nothing, my result is
HD:Applications:myFolder:
Which is what I want.

It works fine on my powerbook g4 w/ tiger, a friends intel macbook w/ tiger… But not a macbook w/ leopard.

Does leopard not like the fact that I have spaces in my app name? Or is it something else?


set appsPath to path to me as string
set the myPath to appsPath

set the myPath to replace_chars(appsPath, "My Path Tester.app:", "") -- function not shown in this snippet, but you can figure out what it does

display dialog "This is the path to prefs from the main app ->
" & myPath

Hi Susan,

path to me has a different behavior in Tiger and Leopard when the script is started from Script Editor

To get the parent directory of a file, this is an easier way


set myPath to path to me as Unicode text
set {TID, text item delimiters} to {text item delimiters, ":"}
set myPath to text items 1 thru -2 of myPath as Unicode text
set text item delimiters to TID

display dialog "This is the path to prefs from the main app ->
" & myPath

ill try your solution - but first…

will it also have a difference if my app is not run from the Script Editor but saved as an application and then double clicked?

No