Skip to content

Instantly share code, notes, and snippets.

@adamwalter
Created February 21, 2019 21:01
Show Gist options
  • Save adamwalter/1bb675bbe6350a06c4f22da02fb8a43b to your computer and use it in GitHub Desktop.
Save adamwalter/1bb675bbe6350a06c4f22da02fb8a43b to your computer and use it in GitHub Desktop.
Bulk import WordPress featured images
#!/bin/bash
# File names should be suffixed with "_{postid}"
# example_42.jpg
for filename in ./photos/*.jpg; do
ID1=$(echo $filename| cut -d'_' -f 2)
ID2=$(echo $ID1| cut -d'.' -f 1)
wp media import $filename --post_id=$ID2 --featured_image
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment