#!/bin/bash -eif [ $# -ne 2 ]; then echo >/dev/stderr "ERROR: Incorrect number of arguments." cat <<EODUsage: ./`basename "$0"` LIST NAMEArguments: LIST File containing names of files to rename. NAME Beginning of pattern to rename files to.EOD exit -1fiif [ "$1" == "-" ]; then FILELIST="/dev/stdin"else FILELIST="$1" if [ ! -f "$FILELIST" ]; then echo >/dev/stderr "ERROR: Could not read file list '$FILELIST'." exit -1 fifiNAMEPATN="$2"i=1while read FIN; do if [ ! -f "$FIN" ]; then echo >/dev/stderr "WARNING: Could not find source file '$FIN'. Skipping..." continue fi FOUT=`printf "$NAMEPATN.part%03d.rar" $i` if [ -f "$FOUT" ]; then echo >/dev/stderr "WARNING: Target file '$FOUT' alread exists. Skipping..." continue fi mv -v "$FIN" "$FOUT" i=$[$i+1]done <"$FILELIST"