File to Clipboard as Content?

Hi,

I’m trying to improve upon a script which has been written to transfer a selected file from Itunes to Ableton. Unfortunately, it seems like Ableton has no Applescript support, so the only option is to use the clipboard as an intermediary. We’ve already managed to produce some working code using keystrokes and show finder, but it would be much neater if we could simply pass a file handle to clipboard and tell it to copy the raw data.

I have had a search around here and the net, but nearly all of the examples I have seen concern converting text. The only exception being this thread here:
http://macscripter.net/viewtopic.php?id=12668

This was inconclusive, although it did seem that this may not be possible. What I have managed to achieve is the following:

set clipboard to (read theTrackName as file)

where theTrackName is an alias to an audio file. The result of this script is that the raw data is copied to the clipboard, but it does not retain data type - i.e. it pastes as gobbledygook into another application.

I would very much appreciate it if anyone out there knows how to get the data to retain its type.

Many thanks,

James

Hi orge

try this

tell application "iTunes"
	set theTrackName to name of selection as string
	set the clipboard to theTrackName
end tell

Thanks for the suggestion, that just copies the name of the track to the clipboard. I’ve also tried the following:


tell application "iTunes"
	set trackList to the selection of window 1	
	repeat with theTrack in trackList
		set theTrackName to (the location of theTrack)
		tell application "Finder"
			set the clipboard to (POSIX path of theTrackName)
		end tell
	end repeat
end tell

This copies the full path of the file to the clipboard, but Ableton does not recognise it as a track…

Of all the suggestions I have seen, reading the file into the clipboard seems like the most promising avenue. I just have no idea how to specify the right file type…

J

EDIT: have now also managed to get a successful read command, but that doesn’t get recognised as the correct type either!? (i.e. it won’t paste out)

set the clipboard to (read theTrackName as "MPG3")

What is it that the finder is doing differently??