In my last post I described a way to list out all your subscribed feeds that haven't been posted to in four months. This works well, but leaves it up to you to do something with those feeds.

The next logical step is to let PowerShell worry about them. That is, have the script itself automatically delete the feeds, or perhaps move them to a "Dead" folder for you to keep an eye on.

Now, the current version the PowerShell Community Extensions does not have a FeedStoreProvider that supports the "move-item" command, but that'll change soon (I've already written the code). In the meantime, here's how you'd delete the old feeds:

cd feed:\
gci -rec |
   ?{ $_.Type -eq "Feed" } |
   %{ $_.Items | sort -desc PubDate | select -first 1 } |
   ?{ $_.PubDate -lt [DateTime]::Now.AddMonths(-4) -and $_.PubDate.Year -gt 1899} |
   %{ $_.Parent } |
   remove-item -recurse 

Note the "-recurse" parameter on remove-item. That's because feeds are technically containers (they contain feed items), so unless you specify the "-recurse" parameter you will be prompted to delete each feed.

Next, here's how you'd move the old feeds to a "Dead" folder:

cd feed:\
new-item -itemType Folder Dead
gci -rec |
   ?{ $_.Type -eq "Feed" } |
   %{ $_.Items |  sort -desc PubDate | select -first 1 } |
   ?{ $_.PubDate -lt [DateTime]::Now.AddMonths(-4) -and $_.PubDate.Year -gt 1899} |
   %{ $_.Parent } |
   move-item -destination \Dead 

One small caveat: You have to be sitting in the root of your "feed:" drive for this to work. The reason for this is that remove-item and move-item both look for a "Path" property on the item that gets piped through to them, and for feeds the "Path" property is a relative path from the root folder (eg. "Blogs\Mabsterama"). So the commands won't find the item to remove or move unless you're currently sitting in "feed:\".