Format XML Files

Today I found myself looking through hundreds of unformatted XML files. I did some googling and found the following script that makes use of xmllint to format all the files and save copies of them to a ‘formatted’ folder.

find . -maxdepth 1 -type f -iname "*.xml" -exec xmllint --format '{}' --output formatted/'{}' \;

Worked like a charm (on Mac OS).