From 650476e498df0ce3d6d02987e40534883cbf2d3b Mon Sep 17 00:00:00 2001 From: TiynGER Date: Fri, 21 Feb 2020 12:03:55 +0100 Subject: [PATCH] cleanname merges files and doesnt delete randomly --- .local/bin/etc/cleanname | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.local/bin/etc/cleanname b/.local/bin/etc/cleanname index a0598c8..d19c5f0 100755 --- a/.local/bin/etc/cleanname +++ b/.local/bin/etc/cleanname @@ -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