You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
686 B

#!/bin/sh
[ -z "$1" ] && (echo "Error: missing argument (what to remain)" && exit)
for oldname in "$@"
do
newname=`echo "$oldname" | tr '[:upper:]' '[:lower:]' | sed 's/\ /_/g; s/Ö/oe/g; s/Ä/ae/g; s/Ü/ue/g; s/ö/oe/g; s/ä/ae/g; s/ü/ue/g; s/ß/ss/g'`;
if [ "$oldname" != "$newname" ]; then
if [ -f "$newname" ]; then
echo "skipping $newname, because it already exists"
rm "$oldname";
else
if [ -f "$oldname" ]; then
echo "renaming file $oldname to $newname"
cp "$oldname" "$newname" && rm "$oldname";
elif [ -d "$oldname" ]; then
echo "renaming directory $oldname to $newname"
cp -r "$oldname/." "$newname" && rm -r "$oldname";
fi
fi
fi
done