Did you try googling "pretty-print" with your language name? Seems like this is doable if the only thing you are changing is the optional whitespace permitted by the language. You can run diff on the output of a comand-line pretty-printer vs. the original code if you want to raise errors or see differences.
When I've had to work with the most hideous imaginable Java code where the comments were useless (or nearly so), I've used the JAD Java Decompiler on the .class files and set the options to format everything the way I wanted. Sometimes you can do this and cut and paste useful comments from the original. It's nice because you can tell it not to decompile unused code, so you don't waste time reading stuff that never gets called.
Regular Expressions with grep to raise errors
I have a script that I run to capture common errors that I make. For instance, leaving a form with a get instead of a post:
# Enable extended globbing in scripts so I can use !(validate.sh)
# instead of * to mean not this script
shopt -s extglob
egrep --exclude-dir='.svn' --color -rIi "method[ \t]*=[ \t]*['\"]get['\"]" *
I have a bad habit of using an apostrophe with "its" sometimes when I shouldn't, so this checks for spelling mistakes:
# use "its" for possessive
egrep --exclude-dir='.svn' --color -wrIi "(have|keep|change|be|to) it's" *
egrep --exclude-dir='.svn' --color -wrIi "it's own" !(validate.sh)
# use "it's" for a contraction it-is or it-has
egrep --exclude-dir='.svn' --color -wrIi 'its (not|yours|been|finished|on|ever|slow|probably|an?|never|better|possible)' *
Really, you can check for just about anything you dream up. Instead of grepping *, you can grep *.html, or *.rb, or whatever for various kinds of issues.
Regular Expressions with sed to fix errors
Use sed to do replacements
# Strip trailing whitespace and DOS line ending trash
sed -i 's/[ \t\r\n]*$//' myProject/myCo/app/pkg/*
sed -i -e 's/ /\t/g' *.html
Remember, in sed, you have to escape the plus sign to mean "one or more" in a regular expression, otherwise it matches a literal plus. That throws me every time.
Regular Expression Book
Mastering Regular Expressions, 3rd Edition: Understand Your Data and Be More Productive by Jeffrey E.F. Friedl. One of my all-time favorite tech books. Starts off a little slow, ends up a little fast. I think I made it through this book in 2 weeks with a 2-hour/day train ride and a laptop. Have used RegEx ever since for stuff just like this and a thousand other little things as well.