I wrote a quick bourne shell script to sort and rename the image files I recovered from my formatted memory stick. It requires the perl exifdump script that comes with the Image::Info module (not the python script by the same name). Since the last pre-format image I had was 8160, I started the recovered files at number 8161. The filenames will not be exactly right due to images that were deleted and retaken, but close enough.
The script was coded up quickly so there is no documentation or error checking.
#!/bin/sh
#
NUM=8161
PRE=DSC0
EXT=.JPG
TEMPLIST=`/usr/local/bin/mktemp /tmp/ds-rename.XXXXXX`
TEMPSORT=`/usr/local/bin/mktemp /tmp/ds-rename.XXXXXX`
for file in V*.[jJ][pP][gG]
do
echo "Processing ${file}..."
DATE=`/home/jlick/bin/exifdump ${file} 2> /dev/null | /bin/grep DateTimeOriginal | /bin/sed -e "s/.*DateTimeOriginal -> //"`
echo ${DATE} ${file} >> ${TEMPLIST}
done
echo "Sorting..."
/bin/sort ${TEMPLIST} > ${TEMPSORT}
for file in `/bin/sed -e "s/.* //" < ${TEMPSORT}`
do
echo "Renaming ${file} to ${PRE}${NUM}${EXT}..."
/bin/mv ${file} ${PRE}${NUM}${EXT}
NUM=`/bin/expr ${NUM} + 1`
done
/bin/rm -f ${TEMPLIST} ${TEMPSORT}
You may wish to use Image::ExifTool instead of Image::Info as the latter has not been maintained for quite some time now. I’m sure CPAN will probably keep it forever and since you don’t need more advanced tags, it probably doesn’t matter. Still, something to keep in mind.
Yeah, but I already had exifdump and Image::Info installed and know basically how it works. (This script is basically a rewrite of ds-makeslide so a lot of the code was borrowed.)