Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

merlyn (47)

AOL IM: realmerlyn (Add Buddy, Send Message)
Yahoo! ID: realmerlyn (Add User, Send Message)

See my home page [].

Journal of merlyn (47)

Friday September 16, 2005
03:16 PM

applescript to delete already-heard podcasts from iTunes

[ #26743 ]
So, I'm amazed this isn't easier to do. I want to delete the podcasts I've heard. So I created a smart playlist that says "is podcast" and "played count > 0". Hey, looky, there they are. But I can't delete from that window! I have to go back to the podcasts window finding each one over again.

With great trepidation, I fire up the AppleScript Editor. And after staring at the docs far too long again (because every time I look at AS, I go crazy), I came up with this:

-- do this here to get standardaddition value
set trashloc to path to trash

tell application "iTunes"
    repeat with pp in (every playlist whose special kind is Podcasts)
        repeat with p in (every file track of pp whose played count > 0)
            set loc to location of p
            tell application "Finder" to move loc to trashloc
            delete p
        end repeat
    end repeat
end tell

which I'm sharing with y'all to save the pain I experienced.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Option-deleting [] a song from a Smart Playlist will delete it from your iTunes Library. Also, option-deleting a whole playlist will delete the playlist and all of the songs it contains (which is probably not what you want to do with your "Played Podcasts" Smart Playlist).
    • Too many secrets.

      Too much of this is undocumented. {sigh}

      • Randal L. Schwartz
      • Stonehenge
    • Neat. I didn't know about opt-delete.

      Also, because I can ... not that it is any longer necessary, but still:

      use Mac::Glue ':all';
      my $itunes = new Mac::Glue 'iTunes';
      my $podcasts = $itunes->obj(
          playlist  => 1,
          playlists => whose(special_kind => equals => enum('podcasts'))
      my $tracks = $podcasts->obj(
          file_track => whose(played_count => g_t => 0)
      for my $track ($tracks->get) {
          my $locati

  • On my windows version 5.0 of iTunes, you can specify in the Podcasts preferences window which podcasts you want to keep (one option being "All unplayed episodes"). I haven't used this option but presumably it would automatically delete your played podcasts. (I'm also making an assumption that the Mac version has this same option and functionality)
    • "played a few seconds" is not "played all the way through". If you just start listening to a podcast, it's considered "played" by that option. I want to delete only the ones I've heard all the way to the end.
      • Randal L. Schwartz
      • Stonehenge