I am trying to hack together a quick little program that will automatically add any song in a folder directly to iTunes without dragging and dropping. I am not very familiar with the iTunes API/COM/Whatever-the-heck-it-is.
I found some examples online, but they were in WScript or something. When I run my code, I get an "invalid procedure call or argument" on the "ConvertFiles" line. Here is what I came up with:
I don't really want to convert files to another format, but that function was the only thing that looked close to what I wanted.VB Code:
Option Explicit Public App As iTunesApp Public FSO As FileSystemObject Private Sub Command1_Click() Dim FileNames(0) FileNames(0) = FSO.GetAbsolutePathName("C:\Documents and Settings\Bob\Desktop\AAA.mp3") Call App.ConvertFiles(FileNames) End Sub Private Sub Form_Load() Set App = New iTunesApp Set FSO = New FileSystemObject End Sub
Here is what the WScript (or JScript or whatever the heck it is) looked like. Maybe someone can translate. It looks like it is being put in an array and the array is being passed.
Code:http://www.hydrogenaudio.org/forums/index.php?showtopic=21736&st=0&& args = WScript.Arguments; if (args.length != 0) { var iTunesApp = WScript.CreateObject("iTunes.Application"); var encoderCollection = iTunesApp.Encoders; var encoder=encoderCollection.ItemByName("AAC Encoder"); iTunesApp.CurrentEncoder = encoder; var fso = new ActiveXObject("Scripting.FileSystemObject"); fil = new Array(); for (i = 0; i < args.length; i++) { fil.push(fso.GetAbsolutePathName(args(i))); } iTunesApp.ConvertFiles(fil); } else { WScript.Echo("Usage: encodeAAC.js <filename.wav>"); }




Reply With Quote