|
2008-02-26
, 14:24
|
Guest |
Posts: n/a |
Thanked: 0 times |
Joined on
|
#2
|
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/*
The Following 2 Users Say Thank You to For This Useful Post: | ||
![]() |
2008-02-26
, 14:49
|
Posts: 35 |
Thanked: 18 times |
Joined on Feb 2007
@ France
|
#3
|
I am using the Nokia Camera application to take snaps and upload them to twitxr.com but the filenames are strangely formatted which makes finding and storing them differcult.
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.
Any shell gurus in here wanna help ?
Thanks
Last edited by cybergypsy; 2008-02-26 at 14:50. Reason: Solution found , thanks