Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293#!/usr/bin/env zsh
usage() { echo "Usage: $(basename "$0") <images|videos|media> [-x ext ...]" >&2 echo >&2 echo "Prints glob patterns one per line for use in scripts." >&2 echo >&2 echo " images — raster images, raw formats, and modern compressed formats" >&2 echo " raw — camera raw formats (arw, cr2, dng, nef, etc.)" >&2 echo " videos — common video container formats" >&2 echo " media — both images and videos" >&2 echo >&2 echo "Options:" >&2 echo " -x, --exclude ext [ext ...] exclude one or more extensions (without leading dot)" >&2 echo >&2 echo "Examples:" >&2 echo " $(basename "$0") images -x heic heif" >&2 echo " $(basename "$0") images -x jpg jpeg" >&2 echo " $(basename "$0") videos -x wmv flv" >&2 exit 1}
print_raw() { print -l \ "*.arw" "*.cr2" "*.cr3" "*.dng" "*.nef" \ "*.orf" "*.raf" "*.raw" "*.rw2" "*.pef" "*.srw" "*.x3f"}
print_images() { print -l \ "*.jpg" "*.jpeg" \ "*.png" "*.gif" "*.bmp" \ "*.tiff" "*.tif" "*.tga" \ "*.webp" "*.avif" \ "*.heic" "*.heif" \ "*.jxl" \ "*.psd" print_raw}
print_videos() { print -l \ "*.mp4" "*.m4v" \ "*.mov" \ "*.mkv" \ "*.avi" \ "*.webm" \ "*.ts" "*.mts" "*.m2ts" \ "*.wmv" "*.flv"}
# Parse typecase "${1:-}" in images|img|i) type=images ;; raw|r) type=raw ;; videos|video|vid|v) type=videos ;; media|all) type=media ;; *) usage ;;esacshift
# Parse -x / --excludeexcludes=()while [[ $# -gt 0 ]]; do case "$1" in -x|--exclude) shift while [[ $# -gt 0 && "$1" != -* ]]; do excludes+=("$1") shift done ;; *) usage ;; esacdone
emit() { case "$type" in images) print_images ;; raw) print_raw ;; videos) print_videos ;; media) print_images; print_videos ;; esac}
if [[ ${#excludes[@]} -gt 0 ]]; then pattern=$(printf "%s|" "${excludes[@]}") pattern="\.(${pattern%|})$" emit | grep -vEi "$pattern"else emitfi