Go to root folder of your Hugo project. Use below code on terminal. Make sure you back up your content folder first.
find content/posts -name '*.md' -exec perl -pi -E 's/(image\s*=\s*")([^"]*\/)([^\/"]+\.(jpg|jpeg|png|webp|gif))(")/$1$3$5/g' {} +
For other folders (custom post type) within content folder, use below. Replace foldername with the real folder name.
find content/foldername -name '.md' -exec perl -pi -E 's/(image\s=\s")([^"]\/)([^\/"]+.(jpg|jpeg|png|webp|gif))(")/$1$3$5/g' {} +
Leave a Reply