Apple Script Paths on Multiple Computers

Discussion in 'Mac Apps and Mac App Store' started by phooodisgoood, Sep 9, 2014.

  1. phooodisgoood macrumors newbie

    Joined:
    Aug 5, 2014
    #1
    I'm trying to write a script that opens a movie that is packaged within the contents of the app on more than one computer. I can easily drag in the path to the movie on my computer but on another computer it wont work and if the app is placed in a folder or something of that sort it will break yet again because the path will change. How do I open the movie contained within the app regardless of where the app is?

    Heres my code so far:
    tell application "Finder" to set theMovie to "Users:MyName:Desktop:Bat Signal.app:Contents:Resources:Bat Signal MOV1.mp4"
    tell application "QuickTime Player"
    activate
    open theMovie
    play

    end tell

    any help would be greatly appreciated
     
  2. Partron22, Sep 9, 2014
    Last edited: Sep 10, 2014

    Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #2
    Slow and requires admin access:
    Code:
    set aa to do shell script "find /Users -name Bat Signal.app" with administrator privileges
    Fast but requires Spotlight:
    Code:
    set bb to do shell script "mdfind -name Bat Signal.app"
    These'll give you the / delimited path to the file, if it exists.
     
  3. phooodisgoood, Sep 18, 2014
    Last edited: Sep 18, 2014

    phooodisgoood thread starter macrumors newbie

    Joined:
    Aug 5, 2014
    #3
    I originally thought it worked correctly but that was because I happened to have the same file on my desktop but neither method works in finding the movie inside the package contents
     
  4. Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #4
    You added the "Contents:Resources:Bat Signal MOV1.mp4" bit of path to the pathe the search returned, and converted all the / to :?
     
  5. kryten2, Sep 18, 2014
    Last edited: Sep 18, 2014

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #5
    Look at the path to resource section here

    Example :

    Code:
    set theMovie to path to resource "DragFolderToOpenDialog.mov"
    
    tell application "QuickTime Player"
    	activate
    	set movieDocument to open theMovie
    	play movieDocument
    end tell
     

    Attached Files:

Share This Page