Bit of help creating an applescript for itunes..?

Discussion in 'Mac Programming' started by nick0831, Mar 10, 2008.

  1. nick0831 macrumors newbie

    Mar 10, 2008
    Hi Everyone. I'm new, so bear with me.

    I have a central file store with all my tunes on. It's a PC server. I can access all the songs from my Powerbook as I have set the library to point to my main store on the PC.

    I copied the .itl file from the server pc to the mac and had to choose 'hide extension' so that the filename was the same on the PC and mac. Straight away, when I opened Itunes, everything was there as it should be, reading from the server!

    Now, what I want to do, is create an applescript that updates the .itl file from the server to my mac every time I restart it. I'm not very hot with applescript, but essentially, I need it to do the following:

    take file from server
    hide extension *.itl
    replace it with file on my mac

    Can someone please help me out?!

    Thanks so much, and a big hello!
  2. allbrokeup macrumors 6502

    Mar 6, 2008
    Melbourne, Australia
    Try This:

    Get File;

    tell application "Finder"
    of machine (PC) "eppc://"
    duplicate "/Documents And Settings/-USERNAME-/PATH/TO/.ITL/FILE/" to "/Users/-USERNAME-/Music/iTunes/" of machine "eppc://Username:password@The.IP.Address.Here".

    That should get you at least one step of the way.
    (Updated to be smoother and a LOT quicker to understand :D:D)
  3. nick0831 thread starter macrumors newbie

    Mar 10, 2008
    many thanks for this. I will give it a go.

    thanks again!

    Any more help, much appreciated.

  4. cpjakes macrumors 6502

    Aug 15, 2003
    Buffalo, NY
    Maybe other people know better if this works, but can't you just make an alias of the file so there's only one file?

    I would think that with the AppleScript version, you would still need to automount the PC if you weren't already...

  5. allbrokeup macrumors 6502

    Mar 6, 2008
    Melbourne, Australia
    Toggle File Extensions On/Off:

    on open files_
    repeat with file_ in files_
    tell application "Finder"
    if extension hidden of file_ is true then
    set extension hidden of file_ to false
    set extension hidden of file_ to true
    end if
    duplicate file_ to "Macintosh HD:Users:USERNAME:Music:iTunes:"
    on error e
    display dialog e buttons {"OK"} default button 1
    end try
    end tell
    end repeat

    end open

    Paste that into Script Editor or Xcode AppleScript App's Script. It will become a droplet. Simply drag a file onto the Icon and it will Hide the Extension if its showing and vice-versa, also Copy the Dropped Library to the iTunes Music Folder on Mac OS X. Write all other code in the 'On Open' Handler, such as my 'of machine' code. In my other hint, leave out the (PC) and the (MAC) as it was just a guide to show what IP Address to include first. Also please make sure that the PC is connected to your Network or the code I included before won't work.

    Put the 'Of Machine' code in the On Open handler but use:

  6. motulist macrumors 601


    Dec 2, 2003
    Just make an automator workflow. It's super easy, you open automator, hit the record button, and it records all your mouse and keyboard moves. You usually have to tweak it a little after making the recording, but imo making an automator workflow is MUCH easier than making an applescript. At this point applescript is only for things that really require the extra power of applescript, and soon enough automator will probably be capable enough to replace applescript anyway.
  7. nick0831 thread starter macrumors newbie

    Mar 10, 2008
    Wow! Thanks so much. That's great. Thanks very much EVERYONE who's contributed to this thread. I REALLY appreciate all your help. What a great forum.
  8. allbrokeup macrumors 6502

    Mar 6, 2008
    Melbourne, Australia
    glad you like this place :D. Did my code work OK? I actually had to employ that but to copy it from my Mac HD to a Windows PC, it worked. I hope it worked for you, I really do. :D

    On another sort of topic, I have created a big AppleScript App that customizes the Mac OS X Dock, that enables or disables hacks according to system version (notably Leopard and Tiger). Does anyone know where I can upload it for download on the Web for free? or here for that matter? Any help would be great. Beta release is on Google Code ''

    thanks, and I dont mean to make this about me. really hope my hint worked for Nick.


Share This Page