From 9efbd772344ad165a935cbe3a7d7d0dc801cda95 Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Wed, 13 Jan 2021 22:52:25 +0000 Subject: [PATCH] feat(sysutils):Add sysutils and some dir renaming script --- sysutils/bklowerBeforeDoubleDotinDirName.sh | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sysutils/bklowerBeforeDoubleDotinDirName.sh diff --git a/sysutils/bklowerBeforeDoubleDotinDirName.sh b/sysutils/bklowerBeforeDoubleDotinDirName.sh new file mode 100644 index 0000000..371dd6c --- /dev/null +++ b/sysutils/bklowerBeforeDoubleDotinDirName.sh @@ -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 -- 2.30.2