cleanname merges files and doesnt delete randomly

master
TiynGER 5 years ago
parent 22c1731349
commit 650476e498

@ -5,11 +5,16 @@ 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'`; 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 [ "$oldname" != "$newname" ]; then
if [ -f "$newname" ]; then if [ -f "$newname" ]; then
echo "skipping $newname, because it already exists"; echo "skipping $newname, because it already exists"
rm "$oldname";
else else
echo "$newname exists, copying $oldname to $newname" if [ -f "$oldname" ]; then
rsync -a "$oldname/." "$newname" echo "renaming file $oldname to $newname"
rm -r "$oldname"; cp "$oldname" "$newname" && rm "$oldname";
else
echo "renaming directory $oldname to $newname"
cp -r "$oldname/." "$newname" && rm -r "$oldname";
fi
fi fi
fi fi

Loading…
Cancel
Save