Feb 01 2005

Scripting iTunes on Windows with Python

Published by Chris McAvoy at 7:39 am under Python

Yikes, this took longer than I expected. It’s my first COM program. Apple published pretty good documentation, but not great. I think the the real sticking point was the way iTunes wanted directory paths.

This script adds some functionality to the Radio Shark I bought a few days ago. On the Mac, anything you record will be popped into iTunes automatically, not so on Windows. All my recordings are set to go into c:\radio. This script moves them into iTunes. Maybe Radio Shark has a trigger that could kick this off? Otherwise, I’ve set up a scheduled job to run it at 4am.

import win32com.client
from os import listdir, remove
from time import sleep
o=win32com.client.Dispatch("iTunes.Application")
dir='c:/radio/'
files = listdir(dir)
if len(files) > 0:
    for file in files:
        file = dir + file
        t = o.ConvertFile2(file)
        while t.ProgressValue < t.MaxProgressValue:
            sleep(3)
        remove(file)


Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.

  • del.icio.us
  • digg
  • Reddit
  • StumbleUpon

Trackback URI | Comments RSS

Leave a Reply