Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 29 lines (24 sloc) 1.07 KB
#!/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