Script for Deleting Old Podcasts

I subscribe to a lot of podcasts, but I don’t want to keep them in my iTunes library after I’m done listening to them. Is there an Apple Script for automatically deleting podcasts? Thanks

Model: MacBook Pro
Browser: Safari 535.7
Operating System: Mac OS X (10.7)

This will delete any podcasts that you set to 1 STAR. Which you can do from an ipod of iPhone, after you have listened to it.


tell application "iTunes"
	set lib to user playlist "Podcasts"
	set delTracks to 0
	set ofi to fixed indexing
	set fixed indexing to true
	
	-- go through library tracks backwards
	repeat with t from (count of file tracks of lib) to 1 by -1
		
		set aTrack to file track t of lib
		try
			if (aTrack's played count is greater than 0 and aTrack's rating is less than 100) or (aTrack's rating is 20) then
				set floc to aTrack's location
				set dbid to aTrack's database ID
				delete (some track of library playlist 1 whose database ID is dbid)
				tell application "Finder" to delete floc
				set delTracks to delTracks + 1
			end if
		end try
		
	end repeat
	
	set fixed indexing to ofi
	
	if delTracks is 0 then
		display dialog "No tracks deleted." buttons {"Thanks"} default button 1 with icon 1
	else
		try
			set podName to (name of some source whose kind is iPod)
			update podName
		end try
		set ps to " was"
		if delTracks is not 1 then set ps to "s were"
		display dialog "Done. " & delTracks & " track" & ps & " moved to the Trash." buttons {"Thanks"} default button 1 with icon 1
	end if
end tell