#!/bin/bash # Print timestamps for Unix-epoch style filenames commonly used on *chan imageboards # Currently doesn't work for 2ch.hk filenames as it uses 10^-4 seconds since Unix epoch as timestamp # mkdir "timestamped" for FILE_PATH in "$@";do # Removes file system path, also accepts URLs # https://mintboard.org/vichan/bone/src/1696676575662-1.jpg > 1696676575662-1.jpg FILENAME="$(basename "$FILE_PATH")" # Removes extension # 1696329854234.jpg > 1696329854234 TSTAMP="${FILENAME%.*}" # Removes 's' used to denote thumbnails on futaba/wakaba/kusaba/*aba derivatives # 1696329854234s > 1696329854234 TSTAMP="${TSTAMP%s*}" # Removes ordering number after dash '-' used to denote multiple uploads per post on vichan/lainchan derivatives # 1696676575662-0 > 1696676575662 TSTAMP="${TSTAMP%-*}" POST_DATE=$(date --utc -d @$(("$TSTAMP"/1000)) +'%Y-%m-%d %H:%M:%S UTC') echo "$POST_DATE $FILENAME" # Make new file preserving original attributes like creation/modification time # cp -p "$FILE_PATH" "timestamped/$NEW_FILENAME"; done