
Hi Andrew, This works: #!/bin/bash typeset PATH_TO_FILE_DIR=/tmp/somedir typeset oldPattern='6H9A([0-9]+)\.CR2' typeset newPattern='6J9A\1\.CR2' for f in ${PATH_TO_FILE_DIR}/*; do typeset oldName=$f typeset newName=`echo "$f"|sed -r "s#$oldPattern#$newPattern#g"` if [ "$oldName" != "$newName" ]; then echo mv $oldName $newName mv $oldName $newName fi done You just need to change /tmp/somedir to the directory where the files are, then save the text above as a script, say renamefiles and then do a: chmod u+x renamefiles then run it via: ./renamefiles It will print out all the files it finds and changes. Hope that helps Andrew Voumard ________________________________ From: luv-main <luv-main-bounces@luv.asn.au> on behalf of Andrew Greig via luv-main <luv-main@luv.asn.au> Sent: Monday, 7 October 2019 7:46 PM To: luv-main@luv.asn.au <luv-main@luv.asn.au> Subject: Renaming files Hi all, My camera has just ticked over 10,000 images in around 8 months, and so another folder has opened up on the SD card, prior to today the file folder was 100EOS5D, the new folder is 101EOS5D, but the counter has reset from 6H9A9999 to 6H9A0001. At this rate I cannot afford to have the same file numbers repeating in the same calendar year. I can go into the Camera and change the file numbering to 6J9Axxxx, but how can I run a bulk renaming of my Raw Files - not being a scripter I am at a (self imposed) disadvantage, I have tried to understand the several ways to achieve this,but I have not grasped it. Rename 6H9A0001.CR2 6J9A0001.CR2 Rename 6H9A0002.CR2 6J9A0002.CR2 Rename 6H9A0003.CR2 6J9A0003.CR2 Rename 6H9A0004.CR2 6J9A0004.CR2 to Rename 6H9A0085.CR2 6J9A0085.CR2 Any help would be gratefully received. Andrew Greig _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main