cleanname merges files and doesnt delete randomly

master
TiynGER 5 years ago
parent 0d06ba25ba
commit 983ccc4035

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

Loading…
Cancel
Save