Adding files to iTunes

I am working on a script to sync iTunes libraries between two users sharing the music files location. Each user has his own library file and preferences.

The script compares a list of locations in the current users iTunes library to a list of the actual files in the music library directory. If a file in the directory is not in the user’s iTunes library (ie, a different user has added a file), the script adds it.

Question is, can I add the file to the current user’s library without making a duplicate file? I would guess that if I changed the preferences in iTunes to not make a copy of the file it would be fixed, but I would prefer to leave that preference set for manual imports. Maybe part of the script would change the preference then change it back (although I don’t know how to do that).

Here is the script so far (definitely not finished yet):

tell application "Finder"
	set musicFolder to folder "Users:Shared:Music:iTunes:iTunes Music" of startup disk as string
	set theListofFiles to (files of entire contents of folder musicFolder) as alias list
end tell
tell application "iTunes"
	using terms from application "iTunes"
		set theListofTracks to location of file tracks of library playlist 1
	end using terms from
	set qtyFiles to 0
	repeat with i in theListofFiles
		set theFile to i as alias
		if theListofTracks does not contain theFile then
			set qtyFiles to (qtyFiles + 1)
			add theFile to library playlist 1
		end if
	end repeat
end tell

If it matters, this is for iTunes 4.9 on 10.4.2. I’m not sure if I’ll run into trouble when I go to iTunes 6 or not.

Thanks,

T.