Created
February 21, 2019 21:01
-
-
Save adamwalter/1bb675bbe6350a06c4f22da02fb8a43b to your computer and use it in GitHub Desktop.
Bulk import WordPress featured images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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