summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-08-09 13:25:00 -0700
committerxyz <gky44px1999@gmail.com>2021-08-09 13:25:00 -0700
commit41cda9a776fa7ca3622f072a0a70b6725fd8a812 (patch)
treefb157f038c7428447b41aebd6c1680bfaa732114
parent457131b0d3ee72ac8913299aafa6893f44dc59e3 (diff)
remove orgext -e option, -e need recursive and not option for better usage, too much to fit in this script
-rwxr-xr-x.local/bin/orgext8
1 files changed, 1 insertions, 7 deletions
diff --git a/.local/bin/orgext b/.local/bin/orgext
index e4058f97..36960bd7 100755
--- a/.local/bin/orgext
+++ b/.local/bin/orgext
@@ -4,11 +4,6 @@
# references:
# https://stackoverflow.com/questions/1842254/how-can-i-find-all-of-the-distinct-file-extensions-in-a-folder-hierarchy
-getext ()
-{
- find . -maxdepth 1 -type f | awk -F. '!a[$NF]++{print $NF}'
-}
-
outdir ()
{
find . -type f -execdir mv -t "$PWD" '{}' \+
@@ -18,13 +13,12 @@ outdir ()
# may further optimize by output file extension names to a variable and use it for both mkdir and mv, current is fast enough for me
indir ()
{
- getext | xargs mkdir
+ find . -maxdepth 1 -type f | awk -F. '!a[$NF]++{print $NF}' | xargs mkdir
# don't know why -print0/-0 for find and xargs doesn't work here
find . -mindepth 1 -maxdepth 1 -type d -execdir basename '{}' \; | xargs -I _ find . -maxdepth 1 -type f -name '*._' -execdir mv -t '_' '{}' \+
}
case "$1" in
- '-e') getext;;
'-o') outdir;;
'-i') indir;;
*) outdir; indir;;