Cleaning up your Podcasts
Wed May 09, 2007 · 358 words

I was running out of HD space again and for the heck of it checked how much space my downloaded podcasts were taking up - 1.9GB. This wasn't that surprising, but I did notice there were media files of podcasts lying around that I had unsubscribed from a looong time ago. So I needed something that would do two things:

a) Delete all the podcasts I had already listened to b) Go through all the residue in the Podcast folder and delete whatever I had already unsubcribed from.

I subscribe to 14 shows so this wouldn't have been much of an issue to do by hand, but I decided to use AppleScript. Here's the script that does all that:

    set podcastFolder to alias "hd:Users:filipp:Music:iTunes:iTunes Music:Podcasts:"
    -- first get rid of played podcasts
    tell application "iTunes"
      set deleteThese to every file track of playlist "Podcasts" whose unplayed is false
      set dontDelete to location of every file track of playlist "Podcasts" whose unplayed is true as list

      repeat with thisPodcast in deleteThese
        set thePath to (location of thisPodcast as string)
        delete thisPodcast
        tell application "Finder"
          move item thePath to the trash
        end tell
      end repeat
    end tell

    -- now comb the fs for any rogue shows

    tell application "Finder"
      repeat with something in list folder podcastFolder without invisibles
        set fullpath to (podcastFolder as string) & something
        if dontDelete as string does not contain fullpath then
          move item fullpath to the trash
        end if
      end repeat
    end tell

It's not particularly clever or terse and turned out to be quite the overkill, but it works - my Podcasts take up 56 MB now. Plus I can safely check out all the shows I want and not worry about getting rid of them later (just drop the script into ~/Library/Scripts/iTunes). ;-) This could also be easaily improved to, for example, disregard shows that are unselected (if you have a played show that you really want to keep).

If you ask me, iTunes should just re-evaluate your “Keep” preference for podcasts every time you hit “Refresh”. That way you could clean things up anytime you like, without resorting to this kind of “violence”.


back · essays · credits ·