Remove Bulk Spam Comments from WordPress Export

February 03, 2015

Remove Bulk Spam Comments from WordPress Export featured image

Recently I was responsible for migrating a WordPress site from a 3rd party hosting service to my personal LEMP stack.  The issue with this migration was that there were around 17,000 comments sitting untouched in the comments section creating an excessive amount of bloat in the .XML export, ~51mbs to be precise.

Thankfully I found this handy post from Neil R suggesting SED as a possible solution.  After modifying his solution slightly for OSX, It now removes all comments from the WordPress export via a single command in Terminal.

Shell Command

$ sed '/<wp:comment>/,/<\/wp:comment>/d' export.xml > export.clean.xml

This command will parse a WordPress export.xml, removing each instance of <wp:comment></wp:comment> it finds. Afterwards then saves the results in export.clean.xml.

This post assumes that the user is aware of how to use Mac Terminal to navigate between folders and edit specific files.

Additional Links on SED

headshot photo

Published on

February 03, 2015

griffen.codes

made with 💖 and

2024 © all rights are reserved | updated 52 seconds ago

Footer Background Image