From: Steven Baltakatei Sandoval Date: Wed, 13 Jan 2021 22:52:25 +0000 (+0000) Subject: feat(sysutils):Add sysutils and some dir renaming script X-Git-Tag: 0.3.0~1 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/9efbd772344ad165a935cbe3a7d7d0dc801cda95?ds=sidebyside;hp=cdd1f1a9ef8799e9ddd3d65009387db2fc9550b3 feat(sysutils):Add sysutils and some dir renaming script --- 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