I wish i could remember and credit the original source of this, but i have used this powershell to generate txt versions of my objects.
function global:Script-DBObjectsIntoFolders([string]$server, [string]$dbname){
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
...