Site icon Hip-Hop Website Design and Development

WP CLI: search and replace specific directory name of URL

I am trying to use wp cli (with regex) to search and replace.

I want to change:

domain.com/wp-content/uploads/2020/04/asdnbahsdjhgzw/picture.jpg

to

domain.com/wp-content/uploads/2020/04/picture.jpg

So I want to get rid of the "asdnbahsdjhgzw" part.

Now I tried something like:

wp search-replace "domain.com/wp-content/uploads/(d)/(d)/(d*)/" "domain.com/wp-content/uploads/$1/$2/" --precise --all-tables --skip-columns=guid --regex

BUT

Unfortunately, this isn´t working as I had hoped. I get the following error:

syntax error near unexpected token `('

I also tried the backslash before the (

/(d)/(d)/(d*)/

But no luck.

Perhaps someone knows what could be the issue, apart from me not knowing WP CLI 😉

thanks!