bin: improve find matching

This commit is contained in:
xeruf 2022-11-09 12:45:38 +01:00
parent 0885c8ab23
commit b1404b35c2
4 changed files with 11 additions and 10 deletions

View File

@ -5,7 +5,7 @@ alias scbra='scpr zebra "/srv/funkwhale/data/music${PWD/$MUSIC}"'
findsongs() { findsongs() {
find -regextype posix-extended -maxdepth 1 -type f \ find -regextype posix-extended -maxdepth 1 -type f \
-regex "${1:-.*\.(mp3|flac|wav|m4a)}" -printf "%P\n" -iregex "${1:-.*\.(mp3|flac|wav|m4a)}" -printf "%P\n"
} }
addtopl() { addtopl() {
@ -44,13 +44,13 @@ addsong() {
addalbum() { addalbum() {
mkdir -p "$MUSIC/$1" mkdir -p "$MUSIC/$1"
mkdir -p "$MUSIC_RAW/$1" mkdir -p "$MUSIC_RAW/$1"
f1 -regextype posix-extended -type f -regex "\./(cover|folder)\.(png|jpg|jpeg)" | f1 -regextype posix-extended -type f -iregex "\./(cover|folder)\.(png|jpg|jpeg)" |
while read cover; do while read cover; do
foundcover="true" foundcover="true"
cp -v "$cover" "$MUSIC/$1" && cp -v "$cover" "$MUSIC/$1" &&
mv -v "$cover" "$MUSIC_RAW/$1" mv -v "$cover" "$MUSIC_RAW/$1"
done done
test "$foundcover" || f1 -regextype posix-extended -type f -regex ".*\.(png|jpg|jpeg)" | test "$foundcover" || f1 -regextype posix-extended -type f -iregex ".*\.(png|jpg|jpeg)" |
while read cover; do while read cover; do
cp -v "$cover" "$MUSIC/$1" && cp -v "$cover" "$MUSIC/$1" &&
mv -v "$cover" "$MUSIC_RAW/$1" mv -v "$cover" "$MUSIC_RAW/$1"
@ -72,7 +72,7 @@ formatsongs() {
done done
) )
# fd --no-ignore-vcs --type f --extension opus --exec opusdec --quiet "{}" "{.}.wav" \; ".*" "$@" # fd --no-ignore-vcs --type f --extension opus --exec opusdec --quiet "{}" "{.}.wav" \; ".*" "$@"
find "$@" -type f -name "*.wav" -exec sh -c ' find "$@" -type f -iname "*.wav" -exec sh -c '
f="{}" && f="{}" &&
echo "Converting $f to ${f%.*}.flac" && echo "Converting $f to ${f%.*}.flac" &&
ffmpeg -i "$f" "${f%.*}.flac" -v warning && ffmpeg -i "$f" "${f%.*}.flac" -v warning &&

View File

@ -37,7 +37,7 @@ fileinfo() {
for arg for arg
do case "$arg" in (-*) continue;; esac do case "$arg" in (-*) continue;; esac
$elevate file --exclude elf -E "$arg" $elevate file --exclude elf -E "$arg"
$elevate ssh-keygen -l -f "$arg" 2>/dev/null $elevate ssh-keygen -l -f "$arg" 2>/dev/null || true
# TODO do not grep bitrate but extract properly # TODO do not grep bitrate but extract properly
#probe="$($elevate ffprobe "$arg" 2>&1)" #probe="$($elevate ffprobe "$arg" 2>&1)"
#echo $probe | grep -v -e '00:00:00.04' -e 'ansi' && #echo $probe | grep -v -e '00:00:00.04' -e 'ansi' &&
@ -101,7 +101,7 @@ for arg; do
;; ;;
(*) (*)
case "$(file --dereference "$arg")" in case "$(file --dereference "$arg")" in
(*\ ?udio*) (*\ ?udio*|*\ ADTS,*)
# TODO preconvert aac - |*\ ADTS\ * # TODO preconvert aac - |*\ ADTS\ *
if ! $inspect && which audiowaveform >/dev/null; then if ! $inspect && which audiowaveform >/dev/null; then
img="$tmpfile.png" img="$tmpfile.png"

View File

@ -46,13 +46,14 @@ highlight "s :: recursively remove logs"
highlight "m :: recursively remove mac-files" highlight "m :: recursively remove mac-files"
if [[ $1 =~ "m" ]]; then if [[ $1 =~ "m" ]]; then
find -name '__MACOSX' -print -exec rm -r {} + find -name '__MACOSX' -print -exec rm -r {} +
find -iname '.spotlight*' -print -exec rm -rI {} + find \( -iname '.spotlight*' -o -name 'System Volume Information' -o -name '.fseventsd' \) -print -exec rm -rI {} +
find -name '*.DS_Store' -delete find -name '*.DS_Store' -delete
fi fi
highlight "d :: recursively remove development caches" highlight "d :: recursively remove development caches"
if [[ $1 =~ "d" ]]; then if [[ $1 =~ "d" ]]; then
find -maxdepth 1 \( -name "*.aux" -o -name "*.log" -o -name "*.t[uo]c" -o -name "*.out" \) -print -delete # TODO some matches duplicate log clearing
find -maxdepth 1 \( -name "*.aux" -o -name "*.log" -o -name "*.t[uo][ca]" -o -name "*.out" \) -print -delete
find \( -name 'src' -o -name 'vendor' \) -prune -o \ find \( -name 'src' -o -name 'vendor' \) -prune -o \
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \ -type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
-print -exec rm $i -r {} + -prune -print -exec rm $i -r {} + -prune

View File

@ -4,8 +4,8 @@
# Need to be around E2B mountpoint if it is not the default # Need to be around E2B mountpoint if it is not the default
dir="$(find . "${MNT:-${XDG_RUNTIME_DIR}/mnt}" -maxdepth 3 -name _ISO -type d | grep .)" dir="$(find . "${MNT:-${XDG_RUNTIME_DIR}/mnt}" -maxdepth 3 -name _ISO -type d | grep .)"
test $# -eq 0 || mv -vi "$@" "$dir/LINUX" test $# -eq 0 || mv -vi "$@" "$dir/LINUX"
find "$dir" -name "*32-*.iso" -exec mv -vi {} {}def32 \; find "$dir" -iname "*32-*.iso" -exec mv -vi {} {}def32 \;
find "$dir" -name "*.iso" -exec mv -vi {} {}def64 \; find "$dir" -iname "*.iso" -exec mv -vi {} {}def64 \;
drive=$(mount | grep "$(basename "$dir")" | cut -d' ' -f1) drive=$(mount | grep "$(basename "$dir")" | cut -d' ' -f1)
sudo umount $drive sudo umount $drive
sudo udefrag $drive sudo udefrag $drive