maybe something like this using mediainfo
and exiftool
?
#!/bin/bash
for file in *.jpg *.mp4; do
# Extract date and time from file's metadata
if [[ $file == *.jpg ]]; then
datetime=$(exiftool -DateTimeOriginal -d "%Y%m%d_%H%M%S" "$file" | awk -F': ' '{print $2}')
else
datetime=$(mediainfo --Output="General;%File_Modified_Date%" "$file" | awk -F' ' '{print $1"_"$2}' | tr -d ':' | tr -d '-')
fi
# If datetime was found, rename the file
if [ -n "$datetime" ]; then
# Extract extension of file
ext="${file##*.}"
# Rename file with date and time as prefix (remove echo after testing it)
echo mv -- "$file" "${datetime}.${ext}"
fi
done