WordPress Upgrade File Deletion

I upgraded another WordPress installation and was annoyed by the “delete these files, but not these files” part of the upgrade. So I decided to come up with an easy way to remove “all the files except these”:

cd /path/to/wordpress
ls > list

Remove from this file those files that you want to keep (what they list plus your other personal files – sitemaps, etc)

vi list

Then delete the ones that are left:

for i in `cat list`; do rm -rf $i; done