mooc/filesystem/home/carole/A44/nname.sh

21 lines
347 B
Bash
Raw Permalink Normal View History

2023-01-31 08:45:52 +04:00
#!/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