Scripting help: application launching

Discussion in 'Mac Programming' started by mac'n'nz, Nov 7, 2012.

  1. macrumors newbie

    Joined:
    May 17, 2010
    Location:
    Havelock North, New Zealand
    #1
    Hey all. I have an external drive with my entire iTunes media folder on it, linked to iTunes . If the external is ejected or turned off , iTunes cannot locate the files .

    This has happened a couple of times by accident . It's easy to reload the media ( exit iTunes and re-open it) but the album artwork seems to stuff up . Eg heaps of missing artwork , swapped artwork etc.

    I was wondering if its possible to run a script that will display the message "'please make sure external hard drive Is on before opening iTunes" when iTunes is opened .

    It could either delay by 10 seconds or so, or even better ask " is the external on" and if the answer is "yes" then iTunes will open .

    Forgive my noobness, only ever done windows batch files so my knowledge is very little .

    Thanks in advance guys :)
     
  2. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Try this :

    Code:
    -- Change POMP to the name of your external disk
    -- iTunes will only launch if the disk exists eg visisble in Finder
    tell application "Finder" to set diskExists to exists disk "POMP"
    set theResult to button returned of (display dialog "Is the external on" buttons {"Cancel", "Yes"} default button 2)
    if theResult is "Yes" and diskExists then
    	tell application "iTunes" to launch
    else
    	display dialog "Disk \"POMP\" is not on."
    end if
    
    There are other ways to do this but you can give it a go.
     
  3. thread starter macrumors newbie

    Joined:
    May 17, 2010
    Location:
    Havelock North, New Zealand
    #3

    Sorry - what is POMP ETC?
     
  4. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    POMP is the name of my USB stick I used as an example. When you plug in your external drive it should be visible with a name under DEVICES in the Finder Sidebar. If not go to Finder-->Preferences and make sure External Disks is checked in the Show these items in the Sidebar section of the Sidebar tab.
    So if the name of your external drive is MyBigDiskWithMyEntireiTunesMediaOnIt then replace POMP in the script with MyBigDiskWithMyEntireiTunesMediaOnIt.
     

    Attached Files:

Share This Page