Last active
August 29, 2015 14:12
-
-
Save mayukojpn/aea046a26e98d672d89f to your computer and use it in GitHub Desktop.
"12345/12345.jpg" みたいな形式の名前のファイルを、親ディレクトリに出してあげる。
This file contains hidden or 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
| files="*" | |
| for filepath in ${files} | |
| do | |
| if [ -e ${filepath}/${filepath}.jpg ]; then | |
| mv ${filepath}/${filepath}.jpg ${filepath}.jpg | |
| rm -rf ${filepath} | |
| echo "UPDATE wp_posts SET post_content=REPLACE(post_content,'${filepath}/${filepath}.jpg','${filepath}.jpg');" >> sql_replace.sql | |
| echo ${filepath}.jpg removed >> log.txt | |
| else | |
| if [ -e ${filepath}/${filepath}.png ]; then | |
| mv ${filepath}/${filepath}.png ${filepath}.png | |
| rm -rf ${filepath} | |
| echo "UPDATE wp_posts SET post_content=REPLACE(post_content,'${filepath}/${filepath}.png','${filepath}.png');" >> sql_replace.sql | |
| echo ${filepath}.png removed >> log.txt | |
| else | |
| echo ${filepath} not removed >> log.txt | |
| fi | |
| fi | |
| done | |
| read wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment