Created
January 17, 2018 03:24
-
-
Save sekitaka/9d8f045cad0779b9f3086156e15305a3 to your computer and use it in GitHub Desktop.
rename multi files
This file contains 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
#!/bin/bash | |
# カレントディレクトリ以下の*.pngファイルを再帰的にループ | |
for FILE_PATH in `find . -name *.png`; do | |
FILE_NAME=`basename $FILE_PATH` | |
DIR_NAME=`dirname $FILE_PATH` | |
# ハイフンをアンダースコアに置換 | |
NEW_FILE_NAME=${FILE_NAME//\-/_} | |
NEW_FILE_PATH="${DIR_NAME}/${NEW_FILE_NAME}" | |
# ファイル名を変更 | |
mv $FILE_PATH $NEW_FILE_PATH | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment