relative file paths?

Hi everybody,

I’m wondering if there’s an easy way to tell an application to open a file relative to the location of the executing script.

For example, I need to open a video file in QT, make it full screen and set it to loop on boot up. The idea is that the script that automates this will live in a folder with the video file and someone can just copy the folder from computer to computer and it will continue to work.

I was hoping that something as simple as…

tell application "QuickTime Player"
	open ""
end tell

…would work, but it looks like that path is relative to the QuickTime application, not the executing script. Is this correct?

I’ve come up with (what seems to me) a convoluted way to do it (posted below). I was just wondering if there’s an easier way. Thanks!

-- get path of script
set _thispath to path to me as string
-- put path in array
set AppleScript's text item delimiters to ":"
set _list to text items of _thispath
-- strip unwanted stuff
set _list to items 1 thru ((count of _list) - 1) of _list
-- build path string
set _filepath to _list as text
set _f to _filepath & ""


try this:

tell application "Finder" to set _filepath to (container of (path to me) as string) & ""

path to me doesn’t work properly when starting the script in Script Editor


thanks for the reply!

I put a description of what I needed and how I solved it on my blog here.

Thanks again.