• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Notes to Self

  • Aviation Weather from NOAA Plugin
    • KZZV
    • Bad Shortcode
    • Simple Metar
  • Meetings

Mark Chouinard / July 17, 2014

Super Basic Bash Script for WP-CLI Import

Did my first WordPress import today using wp-cli.  After unzipping the export file, I was looking at 157 xml files.  Seemed plausible I could just point wp-cli import to the folder containing them, but all I got was an error: This does not appear to be a WXR file, missing/invalid WXR version number.

Fortunately, I recently began working at 10up and am surrounded by tons of brilliant people willing to lend a hand.  The first suggestion I got after finding out I couldn’t point wp-cli to a folder was you can write a super simple bash script to hit each file in a directory.  ‘Great’ I thought, but before I could even open one of my many PDFs on shell scripting I had an email with a pre-made script that only needed minor adjustments to work for what I needed.  And while I was contemplating those adjustments, I got another message, in HipChat this time.  And this time with nearly exactly what I needed.

for f in dir/*.xml; do wp import $f --authors=skip --skip=attachment --url=mysite.dev/; done

I sure miss being a Stay-at-Home Dad, but I sure love doing this job!

Filed Under: WordPress Tagged With: Command line, WordPress, wp-cli

Primary Sidebar

Post Archives

  • June 2024
  • December 2022
  • July 2022
  • December 2021
  • October 2021
  • June 2021
  • February 2021
  • October 2020
  • September 2020
  • August 2020
  • March 2020
  • February 2020
  • December 2019
  • September 2019
  • June 2017
  • May 2016
  • April 2016
  • March 2016
  • September 2015
  • August 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • June 2013
  • May 2013
  • April 2013
  • February 2013
  • January 2013
  • December 2012
  • January 2011

Footer

Copyright © 2025 · machouinard · Log in