Last active
December 27, 2017 00:32
-
-
Save yoosefi/3d5841e0c2b71edf02eec0730249128f to your computer and use it in GitHub Desktop.
sets video file mtime to its encode date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# sets video file mtime to its encode date | |
# requires mediainfo | |
# see also the inverse of this script: "encode-date-from-mtime.sh" | |
# https://gist.github.com/yoosefi/66d9a58466fb9e8bf5a8467fc11f470e | |
set -eu | |
for each in "$@"; do | |
x=($(mediainfo "${each}" | grep -m1 'Encoded date')) | |
# skip null dates | |
if [ -z "${x}" ]; then | |
echo no date for \""${each}"\" >&2 | |
continue | |
fi | |
# skip bogus dates | |
if ! [[ "${x[4]}" =~ ^(199)|(20).* ]]; then | |
echo bad date for \""${each}"\" >&2 | |
continue | |
fi | |
touch --date="${x[*]:3}" "${each}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment