summaryrefslogtreecommitdiff
path: root/home/xyz/.local/bin/orgext
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-10-24 01:05:49 -0700
committerxyz <gky44px1999@gmail.com>2021-10-24 01:05:49 -0700
commit5997d1d96d92e389ca5e4301a7974f4b535a12d5 (patch)
tree5434bcf2507cec03d771a27d728bccad3cca7419 /home/xyz/.local/bin/orgext
parent1ecd63bf0fafdd5fad56f26326d939c66953f6d8 (diff)
refactor
Diffstat (limited to 'home/xyz/.local/bin/orgext')
-rwxr-xr-xhome/xyz/.local/bin/orgext10
1 files changed, 4 insertions, 6 deletions
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