Skip to content

Instantly share code, notes, and snippets.

@tomoyanonymous
Created February 1, 2019 10:26
Show Gist options
  • Save tomoyanonymous/63af94185ed5ca31523557e4fd8772fe to your computer and use it in GitHub Desktop.
Save tomoyanonymous/63af94185ed5ca31523557e4fd8772fe to your computer and use it in GitHub Desktop.
#!/bin/bash
cd `dirname $0`
IFS='
'
for file in $(find content -type f -name index.*md ); do
echo $file
cppath=`echo $file|sed -E 's!(.*)/(.*\..*)!\1!g' `
for grep in $(cat $file | grep -e "JPG" -e "jpg" -e "png" -e "svg" -e "" ); do
echo "grepped $grep"
img=`echo $grep| sed -E 's!(.*)(\(| |"|/)(.*)(\.)([a-zA-Z]{3,4})(.*$)!\3\4\5!g' `
echo "img: $img"
imgpath=`find static -type f -name $img`
echo "copy $imgpath to $cppath"
cp -a $imgpath $cppath
done
# cat $file | sed -E 's$(/?assets/img)(.*)/(.*)(\.)([a-z]{3,4})$\3\4\5$' > tmpfile
# mv tmpfile $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment