When I use exiftool to get the duration of an audio file, if the file is over 24 hours I get “1 day 1:23:45” instead of 25:23:45. Sometimes I get “approx 13:17:23”.
Is it possible to tell exiftool to only return HH:MM:SS regardless of how long the file actually is and if it thinks the time is approximate or not (I can strip out the approximate if I have to, but if there’s a way to specify the output format I can’t find it)?
exiftool -d "%H:%M:%S" -Duration Audiobook.m4a
Duration : 1 days 1:17:20
This works, assuming there its no way to get exiftool to output the hours:
if [[ $DURA == *"days"* ]]; then
EXIF=$(exiftool -duration# "$FILE")
SEC=$(awk -F": " '/Dura/ {print $2}' <<<"$EXIF" |awk -F'.' '{print $1}')
HOR=$(($SEC / 3600))
MIN=$(($SEC % 3600/60))
SES=$(($SEC % 60))
DURA="$HOR:$MIN:$SES"
fi