iTunes - Move aged file to trash from a smart playlist [Moved to OS X]

Anyone have a script that does the following:

  1. You have predefine smart lists in itunes.
  2. The script gets the last played date of the files in that smart list.
  3. If the last played date exceeds a month, week or days (or specified).
  4. The script moves that file to the trash from the library.

thanks in advance.
itunes has a global setting but not very helpful in this case.

Thanks again :slight_smile:

Hmm doesn’t seem to be functioning… for some reason.

No files are moved to trash that meet criteria.

Strangest thing it’s working now… Thanks again…

Revisiting this. It’s been working for the longest time but now I get the following error:

Can’t get location of {file track id 7583 of library playlist id 4934 of source id 39 of application “iTunes”}.

Anyone have some insight to fixing this?

ahem “Jacques:stuck_out_tongue:

The error message says: Can’t get location of the list file track .
For some reason I don’t know iTunes returns a list even you filter first track of

this should fix it, make sure that the parentheses are exactly at these places


.
set this_track to item 1 of (first track of library playlist 1 whose database ID is This_id)
.

Thanks… that fixed the issue.

PS: I recommend to consider both the list and the flat track result


.
set this_track to (first track of library playlist 1 whose database ID is This_id)
if class of this_track is list then set this_track to item 1 of this_track
.

Stefank,

I’m assuming that this is better because it’s processing an list rather than individual elements?

thanks

my surprise was, that iTunes returns a list at all using this filter construction.
In all other cases I know, the syntax

1st element of whatever whose name is something

results the element, not a list containing the element.

If Apple will conform this behavior in the future, your script will work anyway :wink:

thanks again appreciate the reply…

Hello all,

Looks like the above script is broken in itunes 8:

error:

Any help would be greatly appreciated.

Apparently the fix was to revert back to the original script.

For what purpose do you need the database IDs?

no particular need actually. It’s just how the script ran. Haven’t had an opportunity to look thoroughly through the code.

although this is not documented in the dictionary

library playlist 1 of application "iTunes"

refers to the main music library