Feb 01 2005
Scripting iTunes on Windows with 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)



