Nico's is missing the '\n'. It should be:
rm -rf /tmp/failed /tmp/success
mkdir /tmp/failed /tmp/success
RPMLIST=`rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'`
for name in $RPMLIST; do
yum reinstall $name -y 2>/tmp/failed/$name >/tmp/success/$name
done
There are reasons I do them one at a time, and record the results.
It's also possible to manipulate with "--excluderepo=" and
"-includerepo" options, and store the errors.