Mercurial > bins
view tools/add_num_prefix @ 4:c5749e43b1d7
Adding debian files (to original 1.1.29)
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Wed, 15 Oct 2008 23:35:35 +0200 |
parents | a84c32f131df |
children |
line wrap: on
line source
#!/bin/sh # Add a numeric prefix starting at $1, incrementing by $2 on $3..$n files # (c) 2005 J?r?me SAUTRET <jerome@sautret.org> # This script is distributed under GNU GPL. Ask Stallman for details. # $Id: add_num_prefix,v 1.1 2005/08/22 19:58:27 jerome Exp $ set -o errexit if [ -z "$3" ] ; then cat <<EoF Usage: `basename $0` start step files... Add a numeric prefix starting at 'start', incrementing by 'step' on 'files'. EoF exit 1 fi set -o nounset min=$1 len=`echo $1|wc -c|sed 's/^ *//'` let len=len-1 min=`echo $min|sed 's/^0*//'` inc=$2 shift 2 files="$@" i=$min for file in $files do new=`printf "%.${len}d" $i `"_$file" echo "$file -> $new" mv "$file" "$new" let i=i+inc done