Skip to content

Instantly share code, notes, and snippets.

@laughk
Created December 24, 2018 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laughk/cdc89068e089e939b89735b0b4a7bbd3 to your computer and use it in GitHub Desktop.
Save laughk/cdc89068e089e939b89735b0b4a7bbd3 to your computer and use it in GitHub Desktop.
exiftool をつかってファイル名から情報拾って exif の日付情報をいれる雑なスクリプト
# file name example
## 2016-04-22 06.21.33.jpg
## IMG_20160503_172044.jpg
TARGET="$@"
# for 2016-04-22 06.21.33.jpg
FILE_DATE=$(echo "${TARGET}" | grep -Eo '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}.[0-9]{2}.[0-9]{2}')
DATE_FORMAT="%Y-%m-%d %H.%M.%S"
# for IMG_20160503_172044.jpg
#FILE_DATE=$(echo "${TARGET}" | grep -Eo 'IMG_[0-9]{4}[0-9]{2}[0-9]{2}_[0-9]{2}[0-9]{2}[0-9]{2}')
#DATE_FORMAT="IMG_%Y%m%d_%H%M%S"
exiftool -overwrite_original_in_place \
-d "${DATE_FORMAT}" -AllDates="${FILE_DATE}" \
"${TARGET}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment