Sonntag, 26. Februar 2023
I wanted to change the file time (creation/access/change) according to the date and time encoded in the filename.
Here are two examples using awk:

For filenames of type '20221206_191944.jpg':
$ for f in *_*; do t=$(echo "$f" | awk -F '[_.]' '{print substr($1$2,0,12) "." substr($2,5,2)}'); echo touch -t "$t" "$f"; done >> ../timestamps.sh

which yields
touch -t 202212061919.44 20221206_191944.jpg

And for filenames of type 'IMG-20220419-WA0005.jpg':
$ for f in *WA*; do t=$(echo "$f" | awk -F '[-]' '{print $2 "0000"}'); echo touch -t "$t" "$f"; done >> ../timestamps.sh

which yields a
touch -t 202204190000 IMG-20220419-WA0005.jpg

... comment