My initial attempt to do this was taking ages. But then I googled and found this

I took the instructions from the above website and made it into something you could cut and paste in one go.

rpm -qa | sort > pkgs.txt
cat > <<EOF
cat pkgs.txt >>
cat >> <<EOF
dnf reinstall \$pkgs
chmod +x
echo "Now run (as root) ./"

All the above does is make a script, that includes the names of all the packages you have installed, and then the script sends the list to dnf to reinstall them all. Just copy and paste the above into a terminal windows (as whatever user) and then run, as root: “./” after this lot: