From 5997d1d96d92e389ca5e4301a7974f4b535a12d5 Mon Sep 17 00:00:00 2001 From: xyz Date: Sun, 24 Oct 2021 01:05:49 -0700 Subject: refactor --- home/xyz/.local/bin/orgext | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'home/xyz/.local/bin/orgext') diff --git a/home/xyz/.local/bin/orgext b/home/xyz/.local/bin/orgext index de5dc695..bc0a18c5 100755 --- a/home/xyz/.local/bin/orgext +++ b/home/xyz/.local/bin/orgext @@ -1,18 +1,16 @@ #!/bin/sh -# references: -# https://stackoverflow.com/questions/1842254/how-can-i-find-all-of-the-distinct-file-extensions-in-a-folder-hierarchy - # not sure if find here need -depth, not sure if mv here need -n and -T outdir () { - find . -type f -execdir mv -nt "$PWD" -- '{}' \+ - find . -mindepth 1 -maxdepth 1 -type d -delete + find . -type f -execdir mvt "$PWD" '{}' \+ + find . -mindepth 1 -maxdepth 1 -type d -execdir rmdir -- '{}' \+ } indir () { + # https://stackoverflow.com/questions/1842254/how-can-i-find-all-of-the-distinct-file-extensions-in-a-folder-hierarchy find . -maxdepth 1 -type f | awk -F. '!a[$NF]++{print $NF}' | xargs mkdir -- - find . -mindepth 1 -maxdepth 1 -type d -execdir basename -az -- '{}' \+ | xargs -0 -I _ find . -maxdepth 1 -type f -name '*._' -execdir mv -t '_' -- '{}' \+ + find . -mindepth 1 -maxdepth 1 -type d -execdir basename -az -- '{}' \+ | xargs -0 -I _ find . -maxdepth 1 -type f -name '*._' -execdir mvt '_' '{}' \+ } case "$1" in -- cgit v1.2.3-70-g09d2