From 0924d9178c59b3e0b3f49007289c33856a7b4912 Mon Sep 17 00:00:00 2001 From: TiynGER Date: Thu, 27 Feb 2020 14:22:06 +0100 Subject: [PATCH] cleanname prefers mv --- .local/bin/etc/cleanname | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.local/bin/etc/cleanname b/.local/bin/etc/cleanname index 54ad8f0..2309ea4 100755 --- a/.local/bin/etc/cleanname +++ b/.local/bin/etc/cleanname @@ -10,11 +10,16 @@ do else echo "renaming file $oldname to $newname" if [ -f "$oldname" ]; then + echo "using mv" mv "$oldname" "$newname"; elif [ -d "$oldname" ]; then - cp -r "$oldname/." "$newname" && rm -r "$oldname"; - else - mv "$oldname" "$newname"; + if [ -e "$newname" ]; then + echo "using cp" + cp -r "$oldname/." "$newname" && rm -r "$oldname"; + else + echo "using mv" + mv "$oldname" "$newname"; + fi fi fi fi