feat(sysutils):Add sysutils and some dir renaming script
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Wed, 13 Jan 2021 22:52:25 +0000 (22:52 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Wed, 13 Jan 2021 22:52:25 +0000 (22:52 +0000)
sysutils/bklowerBeforeDoubleDotinDirName.sh [new file with mode: 0644]

diff --git a/sysutils/bklowerBeforeDoubleDotinDirName.sh b/sysutils/bklowerBeforeDoubleDotinDirName.sh
new file mode 100644 (file)
index 0000000..371dd6c
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+#Desc:Lowercases portion of directory names preceding '..'
+#Usage: lowerBeforeDoubleDotinDirName.sh
+#Example case: If working directory contains directory named
+#  '0xDEADBEEF..Human description', it is renamed
+#  '0xdeadbeef..Human description'.
+
+for dirSlash in ./*; do
+    if [[ -d $dirSlash ]]; then
+       echo "dirSlash:$dirSlash";
+       dir="$(basename "$dirSlash")";
+       echo "dir:$dir";
+       first="${dir%..*}";
+       echo "first:$first";
+       second="${dir#*..}";
+       echo "second:$second";
+       firstNoCaps="$(echo "$first" | tr '[:upper:]' '[:lower:]')";
+       echo "firstNoCaps:$firstNoCaps";
+       newPath=./"$firstNoCaps".."$second";
+       echo "newPath=$newPath";
+       echo "===========================";
+       mv "$dirSlash" "$newPath";
+    fi;
+done