Performing file functions on itunes tracks

I’m very new to applescript but have a done a good deal of programming. It does not seem though that I am able to use applescript to perform functions on tracks in itunes however and was hoping for some guidance. I am basically just wanting to move files to external storage if they are low rating and keep high rated songs on my hard drive but keep them all in my library for when I have the external drive connected.

Any advice would be greatly appreciated.

A great iTunes scripting resource is Doug’s AppleScripts =>



Oh contrair, mofrair:lol:

Applescript is all about controlling files associated with iTunes and playlists and such.

What you want to do could become a nice customized script. Let’s try this approach:

*First use iTunes to create a playlist that updates to your least played songs. Then you can use iTunes or the Finder to move the files to your external drive without deleting them from the master playlist.

From the iTunes “File” menu create a “New Smart Playlist”

Determine how many songs you have in your library. I have 177. That’s small but we’ll use the example.

Here is where your script will be custom; Deselect “Match the following rule:” in the new playlist dialog, select "Limit to _ items selected by least recently played. I chose to use limit to 75 items. You may want to set your limit to 100, 1000, whatever you want sent to the external drive.

Name the playlist “Least Played Tracks”. It is now a self updating list of your least played songs that you can use as your reference to the files to be moved.

tell application "iTunes" to set LeastPlayedTracks to (location of file tracks of playlist "Least Played")

to get access to the files

tell application "iTunes" to set LeastPlayedTracks to (file tracks of playlist "Least Played")

for an iTunes reference

from there you can use the Finder to move the tracks and then refresh your master playlist with an iTunes command, or use iTunes to move the files and update. Let me know if this is what you had in mind and we’ll finish it up. I might end up using this myself.


Here is another approach. You can move the tracks according to the playcount data in the files. Set a play count minimum, and if the file doesn’t meet the criteria, move it.

tell application "iTunes" to set theTracks to (tracks of playlist "Library")

set LeastPlayedList to {}

repeat with thisTrack in theTracks
	set templist to {}
	tell application "iTunes" to set thiscount to played count of thisTrack
	if thiscount is less than 2 then
--I used the playcount minimum to build a list. You can move the files by changing this part. You could also keep this snippet to log what was moved in a list.
		tell application "iTunes"
			copy name of thisTrack to the end of templist
			copy played count of thisTrack to the end of templist
		end tell
		copy templist to the end of LeastPlayedList
	end if
end repeat

return LeastPlayedList