Screenshot time format needs improvement.

It is a nuisance that the screenshots are not listed in order. A fixup script is a nuisance.


As it stands, I have the date format as "2024-09-27 at 7.02.34 PM"
and I would like it to read "2024-09-27_19.02.34" instead.

(I hate spaces in file names -- I use shell scripts a lot.) Reformatting in this way OUGHT to be trivial. (see "date(1)" for how to do it.) However, my Googling around has not led me to any method for doing that. So I either can't find the right instructions or I want to file an RFE to Apple. (You can call me Don Quixote.)


For anyone else who gets here and at least wants a fixup script:


#! /usr/local/bin/bash

prefix=SS
# SS 2024-09-27 at 8.29.23 AM.png

die() {
 echo "FATAL: $*"
 exit 1
} 1>&2

cd ~/temp
set -- "$prefix "*
test -f "$1" || die "No screenshots in $PWD"

for file
do
  f=${file#$prefix }
  time=${f#* at } ; time=${time%.*}
  case "${time##* }" in
  AM ) add=0  ; time=${time% AM} ;;
  PM ) add=12 ; time=${time% PM} ;;
  *  ) die "confusing date format: $f" ;;
  esac
  hour=$(printf "%02u" $(( ${time%%.*} + add )) )
  time=$hour.${time#*.}
  g=${f%% *}_${time}.${file##*.}
  mv "$file" ${prefix}_${g// /-}
done

P.S. This ain't "Monterey" -- it's "Ventura". That would be the latest and greatest for Intel silicon.

iMac 27″ 5K

Posted on Sep 27, 2024 8:59 AM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Screenshot time format needs improvement.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.