diff options
author | xyz <gky44px1999@gmail.com> | 2021-10-24 01:05:49 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-10-24 01:05:49 -0700 |
commit | 5997d1d96d92e389ca5e4301a7974f4b535a12d5 (patch) | |
tree | 5434bcf2507cec03d771a27d728bccad3cca7419 /home/xyz/.local/bin/orgext | |
parent | 1ecd63bf0fafdd5fad56f26326d939c66953f6d8 (diff) |
refactor
Diffstat (limited to 'home/xyz/.local/bin/orgext')
-rwxr-xr-x | home/xyz/.local/bin/orgext | 10 |
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 |