Created
September 29, 2012 08:42
-
-
Save i03nomura1y/3803504 to your computer and use it in GitHub Desktop.
JPGファイル名の先頭に撮影日を追加
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/sh | |
# created date : 2012/03/25 16:39:16 | |
# last updated : 2012/09/29 17:41:05 | |
# 画像ファイルのファイル名先頭に撮影日を追加。 | |
# ex. test.jpg -> 2012_03_25_test.jpg | |
# 2012_03_25_test.jpg -> 2012_03_25_test.jpg (不変) | |
# usage: | |
# $ rename_jpg.sh *.jpg | |
# 引数チェック | |
if [ $# -eq 0 ] ; then | |
CMDNAME=`basename $0` | |
echo "Usage: $CMDNAME FILE [FILE]... " 1>&2 | |
exit 1 | |
fi | |
for FILE_NAME in $@ ; do | |
# 撮影日 | |
DATE=`jhead $FILE_NAME | awk '/^Date\/Time/ { gsub(/:/,"_",$3); print $3 "_"; }'` | |
# ファイル名が 撮影日 で始まってない -> rename | |
if ! echo $FILE_NAME | grep -q "^$DATE" ; then | |
mv $FILE_NAME $DATE$FILE_NAME | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment