Code WordPress

WP CLI Batch Import

Sometimes you may receive your WordPress export XML files broken up into chunks.  When this happens, it can be cumbersome to import each file one-by-one.  Instead, try throwing everything into a sub-folder and running the following shell script:

# Activate the wordpress importer
wp plugin activate wordpress-importer --url=http://localhost/
# Iterate over all of the import files in a given folder.
for f in myfolder/*.xml; do wp import $f --authors=skip --skip=attachment --url=localhost/; done