21 lines
347 B
Bash
21 lines
347 B
Bash
|
#!/bin/bash
|
||
|
# check number of arguments
|
||
|
if [[ $# -lt 2 ]]; then
|
||
|
echo "Usage : $0 prefixe fichier ..." >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
prefixe=$1 ; shift
|
||
|
i=1
|
||
|
for file in "$@"
|
||
|
do
|
||
|
[ ! -e "$file" ] && continue
|
||
|
dir=$(dirname $file)
|
||
|
nom=$(basename $file)
|
||
|
suffix=${file##*.}
|
||
|
newname=$dir"/"$prefixe$i"."$suffix
|
||
|
echo $newname
|
||
|
((i++))
|
||
|
done
|
||
|
exit 0
|
||
|
|