Add exif creation time with correct timezone (TZD) to filename

Hi i have a problem renaming a lot of photo and images files. I use a shellscript in automator to rename them by EXIF date and time. But the time is given by UTC and im living in europe with +0100 in vinter and +0200 in the summer.

Example: a picture from 2020-06-30 taken at 22:22:30
is named "2020-06-30 20/22/30 IMG_0001.jpg"
instead of. "2020-06-30 22/22/30 IMG_0001.jpg"

im using the script:

#/bin/zsh
for f in "$@"
do
    filedate=$(mdls $f | grep kMDItemContentCreationDate -m 1 | awk '{print $3, $4}');
    filename=$f:t
    filepath=$f:h
    mv $filepath/{"$filename","$filedate $filename"}
done

Can i somehow just add +0200 or +0100 to the "filedate...$4" and how?(and then manually order when the number of houser in the name is over 24) or is there a smarter way to ad time zone designator(TZD) to the script? I have not used script before so im completely new to all this. Hopw someone can help me.


To change UTC time to reflect your timezone, run the output of mdls thru the date command. You can also format the output of the date command.

utcfiledate=$( mdls -n kMDItemContentCreationDate -raw  FILE)

date -f '%F %T %z' -j "$utcfiledate" '+%F %T'

To remove the colons from the output

date -f '%F %T %z' -j "$utcfiledate" '+%F %H%M%S'