Add To Itunes library won't work

Ask questions and get answers on how to make Max behave.
Posts: 1
Joined: Thu Jul 20, 2006 6:52 pm

Post by darelon » Thu Jul 20, 2006 7:09 pm

sbooth wrote:I don't know too much about AppleScript- is it necessary to localize the commands? For example, part of the script Max uses looks like:

Code: Select all

	tell application "iTunes"
		set audio_item to (add audio_file to source "Library")
		if playlist_name is not equal to "" then
			set the_playlist to my get_playlist(playlist_name)
			duplicate audio_item to the_playlist
			set result to audio_item
		end if
	end tell
You're right, this is a localization issue. The AppleScript commands are not localized, but the name of the Library source is localized. This name can also be changed by the user, so you cannot count on it being called 'Library' at all times. To reference the library source without using its name, something like this can be used:

Code: Select all

set library_source to first source whose kind is library
set audio_item to (add audio_file to library_source)
or (shorter, but perhaps somewhat less future-proof)

Code: Select all

set audio_item to (add audio_file to source 1)

Post Reply