#!/bin/bash

if [ -z "$1" ]; then
    echo "Provide a directory."
    exit 1
    elif [ ! -d "$1" ]; then
        echo "The provided argument is not a valid directory."
fi

cd "$1" || exit 1

for file in *.jpg
do
    date=$(date +%d%m%Y)
    filename=$(basename -- "$file" .jpg)
    mv "$file" "${filename}_${date}.jpg"

done