Automatically Tidying Your Feeds!
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:\".
Comments
# Sarah White
20/11/2010 1:00 PM
I think this is the answer I've been looking for in regards to removing old posts from Farmville and such. I'm completely computer illiterate when it comes to what you've explained though. I don't know how to get to the "feed" and where to put your code when I get there. Is it possible to "dumb it down" for me? If I can get it to work, I could pass on the information to my other gaming friends.
Thank you!
# mabster
20/11/2010 2:06 PM
You're clear that this has nothing to do with Facebook, right Sarah? It's to do with RSS feeds in Internet Explorer.