What I'm Doing...

Subscribe

Search

Email

  • Memphis, TN 38103 U.S.A. Otto 240cf86e-5cad-11dc-8314-0800200c9a66

Buy Otto a Beer

Currency:

Amount:

Website(Optional):

Amazon Honor System Click Here to Pay Learn More

Get Otto a Gift

My Amazon.com Wish List
Text

20 Oct 2005-10-20 11:01

iTunes Javascripts

Somebody on digg mentioned AppleScripting iTunes on the Mac, but it seems to be less well known that you can write Javascripts or VBScripts for iTunes for Windows.
So, here’s a bunch of scripts I’ve written for various tasks:

I’ve written more, but these are the most general purpose ones.

To use any of them, just download them, rename them to a *.js file, then run them like any other program (double click, select and press enter, type the name from a command prompt, etc). If you have all the defaults in XP or have the Windows Scripting Host installed on other Windows boxes, then the wscript.exe program actually runs the scripts, much like cmd.exe runs batch files. Same idea, anyway. The scripts connect to iTunes as a COM object and use it in that fashion. Works really well and is quite handy for scripting tasks in iTunes. Yeah, it doesn’t actually integrate or anything, but it’s still useful.

Tags: , , , , , , , , , , , ,

Posted in Geekery, Programmery |

106 Comments

  • Avatar Otto Says:

    brendan: iTunes can do this itself. Just choose the “Consolidate Library” menu option. It’ll move all your library files into the iTunes library folders and rename them according to their tags and everything.

  • Avatar brendan Says:

    Hey otto,
    My music is currently stored in a stupidly named folder as I was only testing out iTunes at first. One thing led to another and I’d spent hours and hours getting all the tags perfect with all artwork showing nicely.
    Now I want to move or just rename the folder but with iTunes being an Apple product it’s not so straight forward.
    I have the database moved over to a sensible location and artwork/metadata intact but of course now it can’t find my music in it’s new location.

    I was wondering if it’s possible to modify the RemoveDeadTracks script to update the location path, so something like this:
    if (currTrack.Location == “d:\Music\blah*”)
    {
    currTrack.Location = “new path”

    }

    Is something like that possible?
    Thanks

  • Avatar BorgSPeon Says:

    Do you have a script that will allow you to put a group of files (mp3s) into the podcast directory without subscribing to an rss feed?

  • Avatar Otto Says:

    Ryan, Nik: You cannot “get around” those errors. The error basically means that iTunes is not installed properly. Try reinstalling iTunes.

  • Avatar Ryan Says:

    I used your scripts on an XP machine with itunes 7.7 and it worked perfect!

    BUT I have my main machine running Vista and it does not work. Do you know how I can edit the code to get around this:
    “could not locate automation class named “itunes.application”

    Have you found a fix for Vista?

  • Avatar Nik Says:

    Do you know if they changed things in the latest iTunes 7.7? I had “borrowed” on of your scripts for loading TV shows to iTunes via a batch script. Everything was working great and now I get and error (after upgrading itunes) which says “library not registered”. I have the following two lines in the script.

    var ItunesApp = WScript.CreateObject(”iTunes.Application”);
    var mainLibrary = ItunesApp.LibraryPlaylist;

    I don’t know much or anything about jscript so I’m looking for help from resources I’ve found in piecing together the script that was once working.

    Thanks … any help would be appreciated.

  • Avatar Prod Says:

    Hi. I’m very new when it comes to all of this and i’ve been running AtomicParsley to edit specific tags which you normally can’t accomplish in editing within iTunes itself. The only one left for me is to edit/add LongDescription for my movies in iTunes. I’ve looked everywhere and i can’t find a solution. I downloaded iTunes COM Windows SDK but have no idea how to handle it or how to write those jscripts to edit the longDescriptions which i’ve desperately been trying to achieve. If anyone can write this script for me or at least give me the tutorial on how to accomplish this then please i beg of you to help me. You can contact me by e-mail aswell (cesar_belifs@hotmail.com). I’ve really been trying to find these answers for 2 whole days now 24/7 with no luck at all…i’m using Windows XP. The short description i’ve accomplished which can be edited with AtomicParsley but to edit the long description is a no go for me, the one you can read when you click on the (i) button on the description field on itunes. Please help me on this one. I’de be most thankful for it!

  • Avatar Otto Says:

    If there is a way to do it, then I don’t know what it is.

    Reinstalling iTunes has always fixed it in all the cases I’ve seen.

  • Avatar tinman Says:

    so is there no way to register the automation class manually?
    (sorry if that’s a stupid question)

    otherwise.. I guess I have to pray that the next version of itunes (which shouldn’t be far), will fix it.. but I don’t have high hopes!

  • Avatar Otto Says:

    tinman: That problem only has one cause and one solution. The cause is an incomplete iTunes installation. The solution is a complete removal and reinstall of iTunes. Sometimes you can get it working by simply installing iTunes over itself.

    However, since you’ve tried that already, you’re probably out of luck, because that is the only answer to your problem.

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">