Created
July 20, 2024 08:35
-
-
Save monnoval/27b5431870f236cef6af805fd11958f5 to your computer and use it in GitHub Desktop.
Playstation 5 / PS5 video clip filename to update file creation/modified 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
#!/usr/bin/env bash | |
# This is to parse and update the creation date of video clips taken from | |
# Playstation5 (PS5). For example filenames such as | |
# GameTitle_20240719233528.mp4 | |
# Transferring this file via USB would not retain the creation/modified date | |
# which the below bash code would solve | |
# https://stackoverflow.com/a/43606356 | |
for filename in *.mp4; do # use mp4 or webm | |
[ -e "$filename" ] || continue | |
DATESTRING=${filename#*_} | |
DATESTRING=${DATESTRING%.*} | |
# https://unix.stackexchange.com/a/659291 | |
STAMP=$(busybox date -D %Y%m%d%H%M%S -d "$DATESTRING" +'%Y%m%d%H%M.%S') | |
# https://askubuntu.com/a/711243 | |
touch -a -m -t $STAMP "$filename" | |
DATEDISPLAY=$(busybox date -D %Y%m%d%H%M%S -d "$DATESTRING" +'%c') | |
echo "Updated $filename to have $DATEDISPLAY as creation date" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment