rename_fixed_lenght.sh 202 B

12345678910
  1. #!/bin/sh
  2. ext=$1
  3. prefix=$2
  4. for f in *.${ext}; do
  5. int=`basename $f .${ext} | cut -d '.' -f 2`
  6. new_name=`printf "${prefix}.%0.5i.${ext}\n" $int`
  7. [ ! -f $new_name ] && mv -v $f $new_name
  8. done