Continuing from the comments, you can easily convert the directory name to a date using date -d
in bash. The trick is parsing the directory from the full filename (e.g. /8 February 2011/img - 6676.JPG
). Since it is an absolute path, you will have to use string indexes to chop the leading '/'
regardless whether you use the dirname
command or you simply parse it with bash parameter expansion (which is the simplest here).
Here is a short example showing how to handle the directory you have given. You may need to modify the jhead
commands so test it before you just turn any script loose on all of your photos.
#!/bin/bash
f="/8 February 2011/img - 6676.JPG" ## example filename "$f"
[ "${f:0:1}" = '/' ] && d="${f:1}" ## check/trim leading '/' for dir "$d"
d="${d%%/*}" ## strip filename leaving dir for time in $d
dt="$(date -d "$d" +'%d-%m-%Y')" ## get date from $d in your format
jhdt="$(date -d "$d" +'%Y:%m:%d')" ## get date in format required by jhead
## output dates and commands for jhead
printf "file : \"%s\"\n" "$f"
printf "has date: %s\n" "$dt"
printf "jhead -mkexif \"%s\"\n" "$f"
printf "jhead -ds %s \"%s\"\n" "$jhdt" "$f"
Example Use/Output
$ bash dirtodate.sh
file : "/8 February 2011/img - 6676.JPG"
has date: 08-02-2011
jhead -mkexif "/8 February 2011/img - 6676.JPG"
jhead -ds 2011:02:08 "/8 February 2011/img - 6676.JPG"