Finding the path of a folder inside another script bundle I am new to Applescript. I am trying to write a script to record an audio file and save it to a different script bundle - &quot;PlayPro.scptd&quot; - with the name passed to the script from an Excel file. The path - savePath - seems to be correct but it doesn't work. It does nothing when I run it. Here is my script:
on RecordM4a(RecordName)    
    tell application &quot;Finder&quot;
        set r to POSIX path of ((container of (path to me) as text))
        set r2 to &quot;PlayPro/Contents/Resources/AudioFiles/&quot;
        set savePath to r &amp; r2 &amp; RecordName
        display dialog savePath
        tell application &quot;QuickTime Player&quot;
            activate
            set doku to new audio recording
            start doku
            delay 4
            stop doku
            set newDoc to last item of (documents whose name contains &quot;Untitled&quot;)
            export newDoc in file savePath using settings preset &quot;Audio Only&quot;
            close newDoc saving no
        end tell
    end tell
    tell application &quot;QuickTime Player&quot;
        if it is running then
            quit
        end if
    end tell    
end RecordM4a
Try this. The key issue is probably that you did not include the script bundle extension in r2, which makes savePath incorrect.
tell application &quot;Finder&quot;
    set recName to &quot;audio_rec.m4a&quot;
    set pathName to (container of (path to me)) as text
    --&gt; &quot;MacHD:Users:username:Desktop:&quot; 
end tell

set appName to &quot;PlayPro.scptd&quot;
set intPath to &quot;:Contents:Resources:AudioFiles:&quot;

set afPath to pathName &amp; appName &amp; intPath
--&gt; &quot;MacHD:Users:username:Desktop:PlayPro.scptd:Contents:Resources:AudioFiles:&quot;

tell application &quot;Finder&quot; to open afPath
set savePathName to afPath &amp; recName
--&gt; MacHD:Users:username:Desktop:PlayPro.scptd:Contents:Resources:AudioFiles:audio_rec.m4a&quot;

tell application &quot;QuickTime Player&quot;
    activate
    set doku to new audio recording
    start doku
    delay 4
    stop doku
    set untDoc to front document
    export untDoc in file savePathName using settings preset &quot;Audio Only&quot; with replacing
    close untDoc saving no
end tell

NB I didn't see any intent for requiring posix paths so I removed them. Unless you expect some other script to meddle with your quicktime player windows, you can simplify that reference. I'm assuming that the folder 'AudioFiles' exists already, and that the destination script bundle is in the same folder as this script.
As an aside, why an Excel file? It might be worth considering using csv, which would be easier to get the string from and probably make your process quicker overall as you don't have to deal with Excel just to acquire a few characters. Finally, on the matter of making a good question, it is helpful when the details include what happens. 'It didn't work' isn't helpful at all — you wouldn't have asked the question if it worked. For example, your problem here isn't with quicktime player — as you suggested, it's about referencing a folder correctly.