Skip to content

Instantly share code, notes, and snippets.

@monnoval
Created July 20, 2024 08:35
Show Gist options
  • Save monnoval/27b5431870f236cef6af805fd11958f5 to your computer and use it in GitHub Desktop.
Save monnoval/27b5431870f236cef6af805fd11958f5 to your computer and use it in GitHub Desktop.
Playstation 5 / PS5 video clip filename to update file creation/modified date
#!/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