I'm not a coder, but I need some help with an iTunes script

First, a little background. I have a MacBook Air that I use in conjunction with my MacBookPro (which I use as a primary computer connected to my Cinema display). I buy music on both computers, but I want to keep the MBP as my main repository of music, so I don’t want the iTunes libraries synced. What I would like to accomplish is getting any music that I put on the MBA, to the MBP complete with ratings and album art automagically. The export functionality will not suffice because iTunes includes Playlist names and other such nonsense, so when the file is imported, iTunes will make redundant playlists that have to be manually deleted. I’m not a coder! I can, with great difficulty, be persistent enough to understand a few things, but writing code is not my bailiwick.

Ideally, the code when ran, would:

  1. Look in a certain named smart playlist (ie., “Add to MacBook Pro 5/1/08”). This smart playlist would contain all music added after 5/1/08.
  2. Copy the album art to the actual music file
  3. Copy the selected music to a designated folder
  4. Generate an XML file that iTunes could then read using the import function to the same folder
  5. Create a new Smart Playlist that would have the parameters “Date added is after <>”

On the other machine, I would then File>Import, and the music would then be on the new machine with the album art and the correct ratings.

Since I don’t code, I’ve been scouring the net looking for solutions, and have come up with a viable solution for items 2, 3, & 4. I need help with number 1 & number 5, and the problem that I’ve run into with Number 4.

Problem with Number 4:
The generated XML contains the path to the file as it is on the MBA, and for the import to be successful on the other computer, the path needs to be different. I need to be able to have the Location Key String be whatever string I designate, rather than the one culled from the computer itself. This so far, seems to be the biggest hang up in getting everything to work properly.

Here is the applescript I’ve put together so far (a mashup of “Export Selected tracks to XML” by Doug’s Scripts, and another I found to copy the album art to the music, and copy it to a folder).

UPDATE: Even with the “code” function, the first part of the script will not display. They are three defined property’s- XML_open, XML_close, and spacer. They are short XML code, but I can’t seem to paste them in here. Any ideas?

on run
	set stagingFolder to (choose folder name with prompt "Specify a file name and a location") as string
	--set stagingFolder to "MacintoshHD:Users:B:Music:SyncWithMBP"
	tell application "iTunes"
		set selected_tracks to selection
		------NEWLY ADDED-----
		set filesToCopy to {}
		repeat with aTrack in selected_tracks
			if class of aTrack is file track then
				-- embed any downloaded album art into the file
				repeat with anArtwork in artworks of aTrack
					if downloaded of anArtwork is true then
						set theData to data of anArtwork
						set data of anArtwork to theData
					end if
				end repeat
				-- add the song file to the list to copy
				set filesToCopy to filesToCopy & aTrack's location
			end if
		end repeat
		-- copy the files to the staging folder
		tell application "Finder"
			set volume alert volume 0
			duplicate filesToCopy to stagingFolder with replacing
			set volume alert volume 80
		end tell
		-----END OF NEWLY ADDED-----
		if selected_tracks is not {} then
			set filename to ("Selected Tracks.xml") as string
			set new_contents to XML_open
			with timeout of 300000 seconds
				repeat with this_track in selected_tracks
					set new_contents to new_contents & spacer & (my get_data_from_XML(get this_track's database ID))
				end repeat
				set new_contents to new_contents & XML_close
			end timeout
			display dialog "Select some tracks..." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
		end if
		set export_file to stagingFolder & "Selected XML"
		--set export_file to "Macintosh HD:Users:B:Music:SyncWithMBP:Selected XML
		set new_contents to my replace_chars(new_contents, ASCII character of 0, "")
			set f to (open for access file export_file with write permission)
			write new_contents to f as «class utf8»
			close access f
		on error
				close access f
			end try
		end try
	end tell
end run

to get_data_from_XML(dbid)
	set dbid to dbid as text
	set the_command to "perl -e 'local $/ = undef;my $s = <>;while ($s=~m:<key>" & dbid & "</key>(.*?)<dict>(.*?)<key>Track ID</key><integer>" & dbid & "</integer>(.*?)</dict>:sg ) {$t = $&;}print $t;' " & my get_path_to_current_xml()
	return (do shell script the_command) as text
end get_data_from_XML

to get_path_to_current_xml()
	set o to (do shell script "defaults read com.apple.iApps iTunesRecentDatabasePaths") as string
	set xm to text ((offset of "\"" in o) + 1) through ((offset of ".xml" in o) + 3) of o
	return (my replace_chars(xm, " ", "\\ ")) as string
end get_path_to_current_xml

on replace_chars(txt, srch, repl)
	set AppleScript's text item delimiters to the srch
	set the item_list to every text item of txt
	set AppleScript's text item delimiters to the repl
	set txt to the item_list as string
	set AppleScript's text item delimiters to ""
	return txt
end replace_chars