Rename files with bash and regular expressions

  1. for i in *.*; do j=`echo $i | sed 's/abc_\(.*\)\.jpg/def_\1.jpg/g'`; mv "$i" "$j"; done

this example would rename the files abc_001.jpg, abc_002.jpg, ... to def_001.jpg, def_002.jpg ...


About this entry