A file named 43_03_18-250208.jpg was taken on 25th February 2008 at 18:03:43. I would like some help in writing a bash script to rename the same file to 20080225_180343.jpg so that the listing would be sorted automatically.
#!/bin/sh # camrename.sh - Renames Nokia Camera application pictures # v0.01 2008-02-26 by Jussi Ylänen while test -n "$1"; do OLDNAME="$1" NEWNAME="`echo $OLDNAME | sed -re 's/([0-9]{2})_([0-9]{2})_([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})/20\6\5\4_\3\2\1/'`" if test "$OLDNAME" != "$NEWNAME"; then # Remove "echo" below to really rename... echo mv "$OLDNAME" "$NEWNAME" fi shift done
~ $ chmod +x camrename.sh
~ $ camrename.sh /media/mmc1/camera/images/*