Applescript for deleting watched shows and podcasts in iTunes

November 12, 2010

Since switching from my Zune HD to an Apple iPod Touch, I’ve noticed that the iTunes software behaves differently than the Zune Software so far as removing deleted shows. For example, after I watch a TV show, movie, or podcast on my Zune HD I can delete it from my device. Then, when I sync with my PC using the Zune Software the application will see that I deleted the video and will also delete it from my PC as well.

With iTunes, it doesn’t work that way. If I delete a video from my iPod Touch after watching it iTunes will copy the video file back on the iPod Touch when I sync again. The only way I’ve found to have iTunes not sync a watched video on my iPod Touch is to configure iTunes to not sync “watched” videos. As such, I manually have to delete the video from iTunes to remove it from my system. I guess this is better, since you may not want iTunes to accidentally delete a video from your system if you really didn’t fully watch it (or in my case, fall asleep in bed while watching a video and have it run to the end!).

So, I’ve written an Applescript that will search out all the videos marked as watched in iTunes after connecting my iPod Touch and remove them from my Mac. Note, that I’m defining that a video has been “watched” if it has been marked by iTunes to have been played and also has a bookmark of 0.0.

My script also does the same for podcast videos and does a final syncing operation. It seems to work pretty well. Below is the full script that I’m using:

I’ve compiled this script to an application and it sits on my desktop where I can launch it by clicking the desktop icon. As I work more and more with nifty things like Applescripts controlling apps, I really appreciate moving from the PC over to the Mac world.