Recently, we took some videos and pictures with our GoPro
camera which was not used for some time and discharged. Due to that, the date and time configuration of the camera was wrong and the resulting video files had wrong metadata
information in their EXIF
.
To update the dates in the produced video and photo files we used the exiftool
that is shipped in the perl-Image-ExifTool
package.
We usually use Fedora
, so we used dnf
to install the application with all needed dependencies as follows:
sudo dnf install -y perl-Image-ExifTool;
After installing exiftool
, we used the following script to change the dates and times of the media files using an offset between the camera date and the real date:
[download id=”4544″]
#!/bin/bash directory="$1"; echo "Processing '$directory'"; date_change="$2"; echo "Change '$date_change'"; find "$directory" \( -iname "*.mp4" -o -iname "*.lrv" -o -iname "*.jpg" -o -iname "*.thm" \) -type f -execdir sh -c ' image=$1; echo "$image "; old_date=`exiftool -d "%a %b %d %T %Z %Y" -CreateDate -S -s "$image"`; echo -e "\t$old_date"; new_date=`date -d "$old_date $date_change"`; echo -e "\t$new_date"; formated_date=`date "+%Y:%m:%d %H:%M:%S %Z" -d "$new_date"`; echo -e "\t$formated_date"; exiftool "-AllDates=$formated_date" "-TrackCreateDate=$formated_date" "-TrackModifyDate=$formated_date" "-MediaCreateDate=$formated_date" "-MediaModifyDate=$formated_date" -overwrite_original "$image"; ' _ '{}' \;
[download id=”4544″]
Usage Example:
After we extracted the script to a folder we were able to use it as follows:
./mediaDates.sh '/run/media/100GOPRO' '+ 3 years + 6 months + 11 days + 7 hours + 5 minutes';
Notes:
- You need extra disk space to update the file as it creates a copy of it even if you overwrite the original
- If you skip
-overwrite_original
, then a new file will be created - We had to update several date fields in order to be sure that we covered all of them that were visible in the
EXIF
data of the media
Link to an older post that handles a single video each time.
This post is also available in: Αγγλικα