Skip to content

Instantly share code, notes, and snippets.

@aprajnaparamita
Last active October 27, 2025 15:55
Show Gist options
  • Select an option

  • Save aprajnaparamita/65d94d61194d58b9713ada81463fcc5d to your computer and use it in GitHub Desktop.

Select an option

Save aprajnaparamita/65d94d61194d58b9713ada81463fcc5d to your computer and use it in GitHub Desktop.
power
#!/bin/bash
# ---- CONFIG ----
# Source folder to scan
read -rp "Enter source folder path: " SRC
# Destination folder for welding photos
read -rp "Enter destination folder path: " DEST
mkdir -p "$DEST"
# Supported extensions (case-insensitive)
EXTENSIONS=("jpg" "jpeg" "png" "tif" "tiff" "heic" "mov" "mp4" "wmv" "avi")
# ---- SCRIPT ----
# Build find command for all extensions
FIND_CMD=""
for ext in "${EXTENSIONS[@]}"; do
FIND_CMD="$FIND_CMD -iname '*.$ext' -o"
done
# Remove trailing -o
FIND_CMD="${FIND_CMD% -o}"
# Find all files
FILES=$(find "$SRC" -type f \( $FIND_CMD \) )
# Loop through each file
for file in $FILES; do
filename=$(basename "$file")
# Open file for preview
case "${file##*.}" in
mov|mp4|wmv|avi)
open -a "QuickTime Player" "$file" ;;
jpg|jpeg|png|tif|tiff|heic)
open "$file" ;; # default app (Preview)
*)
continue ;;
esac
# Ask user
while true; do
read -rp "Is this a welding photo? (y/n) " yn
case $yn in
[Yy]* )
mv "$file" "$DEST/"
pkill -f "$file" 2>/dev/null
break ;;
[Nn]* )
pkill -f "$file" 2>/dev/null
break ;;
* ) echo "Please answer y or n.";;
esac
done
done
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment