#!/bin/sh # Copyright (C) 2002,2006 Adalbert Prokop, adalbert.prokop(%)web.de # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA declare -i begin declare -i step declare -i pos declare -i power declare -i powern declare -i counter if [ "$#" -ge "6" ]; then step="$5" begin="$4" pos="$3" postfix="$2" prefix="$1" counter=$begin shift 5 for file in "$@"; do longcounter=$(printf "%0${pos}i" $counter) mv -vi "$file" "$prefix$longcounter$postfix" counter=$(($counter+$step)) done else echo "Usage: renumber [files...]" echo echo "There must be at least 6 options given. (This means at least" echo "one file.)" fi