qrenumber 524 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. digits=auto
  3. mindigits=3
  4. if [ "$digits" = "auto" ] ; then
  5. num=$(quilt series | wc -l)
  6. digits=$(expr length "$num")
  7. fi
  8. if [ $digits -le $mindigits ] ; then
  9. digits=$mindigits
  10. fi
  11. quilt series | (
  12. num=0
  13. while read pname ; do
  14. num=$(expr $num + 1)
  15. bpname=$(echo "$pname" | sed 's/^[0-9]\+-\(.*\)/\1/')
  16. if [ $digits = 0 ] ; then
  17. npname="$bpname"
  18. else
  19. npname="$(printf "%.${digits}d-%s" $num "$bpname")"
  20. fi
  21. if [ "$pname" != "$npname" ] ; then
  22. quilt rename -P "$pname" "$npname"
  23. fi
  24. done
  25. )