2018-12-14 00:43:11 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
while (( "$#" ))
|
|
|
|
do
|
|
|
|
|
2018-12-14 01:03:17 +01:00
|
|
|
cd "${1%/*}" # gehe ins Verzeichnis
|
2018-12-14 00:43:11 +01:00
|
|
|
|
2018-12-14 01:03:17 +01:00
|
|
|
FILENAME=${1##*/} # Dateiname ist alles ab dem letzten '/'
|
|
|
|
echo "$FILENAME"
|
|
|
|
|
|
|
|
if ! [ -d ${FILENAME%%-*} ]; then
|
|
|
|
|
|
|
|
mv ${FILENAME} ${FILENAME%%-*}
|
|
|
|
else
|
|
|
|
|
|
|
|
number=1
|
|
|
|
while [ -d ${FILENAME%%-*}${number} ]
|
|
|
|
do
|
|
|
|
number=`expr ${number} + 1`
|
|
|
|
done
|
|
|
|
mv ${FILENAME} ${FILENAME%%-*}${number}
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd -
|
2018-12-14 00:43:11 +01:00
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
#./cutname.sh <Ordner>/*-*
|