Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 8, 2008, 07:56 AM   #1
boffo
macrumors newbie
 
Join Date: Oct 2006
Location: Lambeth
Scripted bulk updates to an iTunes database

Hello,

What's my best bet for scripted bulk updates to an iTunes database?

I want to do pattern-based manipulations on titles of tracks, so for example I want convert

"Concerto in A major RV 552"

to

"RV 552: Concerto in A major".

Supposing the actual string manipulation is a solved problem, how do I go about reading and updating the iTunes database? I assume this has to involve AppleScript, but I have no idea how to do this, or even whether it's capable of regular expression matching. I guess I could always shell out to Perl.

Ideally I'd like to manipulate the iTunes database from Perl, Python or Ruby, if that's possible.

Anyway, all suggestions gratefully received.


Boffo
boffo is offline   0 Reply With Quote
Old Mar 8, 2008, 11:49 AM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
I'm pretty sure you can do this with Ruby or Python via the Scripting Bridge in Leopard.
kainjow is offline   0 Reply With Quote
Old Mar 8, 2008, 04:14 PM   #3
boffo
Thread Starter
macrumors newbie
 
Join Date: Oct 2006
Location: Lambeth
The scripting bridge looks great but I'm still on Tiger. Maybe this'll finally give me a reason to upgrade.
boffo is offline   0 Reply With Quote
Old Mar 8, 2008, 04:41 PM   #4
hhas
macrumors regular
 
Join Date: Oct 2007
Scripting Bridge isn't that good. Appscript is better designed, more reliable, and works on Panther onwards.

Using py-appscript:

Code:
#!/usr/bin/python

from appscript import *

def changename(name):
	# do stuff nere
	return name

t = app('iTunes').library_playlists[1].tracks

for name, id in zip(t.name.get(), t.id.get()):
	newname = changename(name)
	if newname != name:
		t.ID(id).name.set(newname)
If you're on Leopard, just run 'easy_install appscript' in Terminal.app to install py-appscript for the default Python 2.5. For other Python installations, you may need to install setuptools first.

If Ruby's more your thing, you can use rb-appscript instead (the above code will work with minor modification). For Perl, there's Mac::Glue (included in Leopard).
__________________
Learn AppleScript, 3rd edition, Sanderson & Rosenthal:
http://www.apress.com/9781430223610
hhas is offline   0 Reply With Quote
Old Mar 9, 2008, 05:34 AM   #5
eldino
macrumors member
 
Join Date: Mar 2007
Location: Italy
if you are looking for scripts dor iTunes, probably Doug Adams have them!
http://dougscripts.com/itunes/

Amazing collection, can't live without 10 of these.
__________________
Scripting, iTunes, Creative Commons music etc: http://eldino.wordpress.com
eldino is offline   0 Reply With Quote
Old Mar 9, 2008, 07:00 AM   #6
boffo
Thread Starter
macrumors newbie
 
Join Date: Oct 2006
Location: Lambeth
Thanks for prompting me to take a closer look at Doug's AppleScripts. I'm already wondering how I managed without Batch Set Sorting Tags.

Anything you particularly recommend from this collection?

Maybe I just need to learn AppleScript to do the updates I have in mind, which I now think are just setting the Sort Name as a function of track Name. The idea is to be able to define smart playlists to represent the various catalogues of works by classical composers, with the works in catalogue order. For example Deutsch for Schubert, Koechel for Mozart etc. etc.
boffo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
scripted logout preferences not working thecoop Mac Programming 0 Oct 26, 2013 02:02 PM
Using one itunes database across two macs allthegear Mac Basics and Help 1 Aug 17, 2013 08:34 PM
iTunes database corrupt? What happened to iTunes? PinkyMacGodess Mac Applications and Mac App Store 0 May 15, 2013 04:57 PM
Bulk iTunes Video Conversion blevins321 Mac Basics and Help 2 Jul 18, 2012 03:13 PM

Forum Jump

All times are GMT -5. The time now is 08:34 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC