mirror of https://github.com/tiyn/dotfiles
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.
27 lines
758 B
27 lines
758 B
5 years ago
|
#!/bin/sh
|
||
|
[ -z "$1" ] && (echo "Error: missing argument (what to remain)" && exit)
|
||
5 years ago
|
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'`;
|
||
5 years ago
|
if [ "$oldname" != "$newname" ]; then
|
||
|
if [ -f "$newname" ]; then
|
||
5 years ago
|
echo "skipping $newname, because it already exists"
|
||
|
rm "$oldname";
|
||
5 years ago
|
else
|
||
5 years ago
|
echo "renaming file $oldname to $newname"
|
||
5 years ago
|
if [ -f "$oldname" ]; then
|
||
5 years ago
|
echo "using mv"
|
||
5 years ago
|
mv "$oldname" "$newname";
|
||
5 years ago
|
elif [ -d "$oldname" ]; then
|
||
5 years ago
|
if [ -e "$newname" ]; then
|
||
|
echo "using cp"
|
||
|
cp -r "$oldname/." "$newname" && rm -r "$oldname";
|
||
|
else
|
||
|
echo "using mv"
|
||
|
mv "$oldname" "$newname";
|
||
|
fi
|
||
5 years ago
|
fi
|
||
5 years ago
|
fi
|
||
5 years ago
|
fi
|
||
|
done
|