-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate-exif-date
executable file
·28 lines (24 loc) · 1.07 KB
/
update-exif-date
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#=======================================================================================================================
# Description
# Script to update EXIF date of JPEG files based on their names. Files must have extension '.jpg' or '.JPG', and
# their names must start with date in format 'yyyy-mm-dd'.
# Arguments
# $1 Directory with JPEG files. Mandatory.
# Prerequisites
# Requires jhead
#=======================================================================================================================
. "$(dirname "$(realpath "$0")")/common.sh"
# Setup vars
dir_source=$1
USAGE_INFO="Usage: $0 <jpeg_directory>"
# Check the parameters
[[ -z "$dir_source" ]] && usage "No source directory specified"
[[ -d "$dir_source" ]] || err "Directory $dir_source does not exist."
find "$dir_source" -type f -iname '*.jpg' -print |
while read pic_file; do
file_name=$(basename "$pic_file")
file_date=$(echo ${file_name:0:10} | tr '-' ':')
log "$file_name: setting date to $file_date"
jhead -q -ds$file_date -mkexif "$pic_file"
done