#!/bin/bash -e THREADS="$(nproc --all)" THREADS="$((THREADS / 2))" function wait_queue() { for job in $(jobs -p | awk "FNR>=$THREADS"); do wait "$job" done } if [ -z "$1" ]; then set "$(zenity --file-selection --multiple --directory --separator=' ')" > /dev/null fi if [ -z "$1" ]; then exit 1 fi for DIR in "$@"; do cd "$DIR" DIR="$PWD" NEWDIR="${PWD%/*}/$(basename "$DIR")_1080p" mkdir -p "$NEWDIR" for FILE in *; do wait_queue identify "$FILE" 2> /dev/null >&2 \ && convert -resize x1080 "$FILE" "$NEWDIR/$FILE" & done done wait_queue zenity --info --text="Done"