Skip to content

Instantly share code, notes, and snippets.

@tralston
Last active September 14, 2022 12:26
Show Gist options
  • Save tralston/4b8779e016a49ed73ba3466ae319e143 to your computer and use it in GitHub Desktop.
Save tralston/4b8779e016a49ed73ba3466ae319e143 to your computer and use it in GitHub Desktop.
[Change video/photo timestamp to date recorded or taken]
# For mp4, the recorded date can exist as Recorded date or Tagged date. If you want to do this for all the files in a folder, use the following command:
for file in *.mp4; do touch -t "$(mediainfo "$file" | grep --color=never -iEm 1 '(Recorded date|Tagged date)' | sed -r 's/.*([0-9]{4})-([0-9]{2})-([0-9]{2})[T ]([0-9]{2}):([0-9]{2}):([0-9]{2}).*/\1\2\3\4\5.\6/')" "$file"; done
# Some videos will not have that date in the metadata, so you'll have to correct it yourself
touch -t CCYYMMDDHHMM[.ss] file.ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment