How to set filename as image title in the media gallery of Wordpress, using wp-cli ?

In other words, I'd like my image titles, stored in wp-content/uploads to be exactly their image filenames (without the extension ".jpg").

In the end, I'd like the two commands below to ouput the same value, for every image in wp-content/uploads:

$ wp post get 17136 --field='guid'

$ wp post get 17136 --field=title

I'd like to do the following for every image:

wp post update 17136 --post_title=$(echo "$(basename $(wp post get 17136 --field=guid))" | cut -f 1 -d '.')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.