From: John Joyce Date: 2007-12-09T09:17:40+09:00 Subject: Re: Identifying a volume as being an iPod On Dec 7, 2007, at 10:15 PM, has wrote: > On 8 Dec, 00:36, John Joyce > wrote: > >> What I want to do is fundamentally this: >> move some audio files (non-DRM'd, the type you've taken off of CD's >> yourself, and which have already been converted to mp3 or aac >> formats) into the iTunes library. > > Adding audio files to iTunes is easy enough, if typically under- > documented: > > require 'appscript' > include Appscript > > ITunes = app('iTunes') > > files = [ > MacTypes::Alias.path('/path/to/file1.mp3'), > MacTypes::Alias.path('/path/to/file2.mp3'), > ... > ] > > track_refs = ITunes.add(files) # add files to iTunes library > > p track_refs > > > > If you want to add the files to a specific user playlist as well as > the main library playlist, you can supply a reference to that playlist > via the optional :to parameter: > > ITunes.add(files, :to=>app.playlists['your playlist']) > > > > If the tracks are on an iPod that's already listed in iTunes, it may > also be possible to directly copy them in iTunes without having to > muck about in the file system at all. However, I'm not an iTunes guru > so unless there's any other ruby-talkers here who happen to know you > may need to ask on one of the AppleScript lists or look for existing > examples on http://dougscripts.com/itunes for help there. > Wow, excellent has!! That's a great help. the add command is described in the scripting definition as adding to a playlist, so I was very unsure if it would add to the library. Quick question for you: can AppleScript like that be used with iTunes for Windows as well? If you have any other appscript or applescript tips, general ones even, by all means clue me in! Making sense of sdef libraries is definitely a tough thing to do with the sparse docs. You basically, just wrote the other half of my script for me! Now, I'm going to give it a simple GUI so users don't need to muck about with the terminal. by the way, is appscript the same as the appscript-rb gem? Seems to be. I picked up the OREILLY AppleScript book, seems useful.