28 lines
801 B
Bash
Executable File
28 lines
801 B
Bash
Executable File
#!/bin/bash -eu
|
|
|
|
XARGS=(xargs -0 -P"$(nproc --ignore=4)" -I'{}' bash -c)
|
|
function compress() {
|
|
local cmd files total newdir progress=0
|
|
|
|
files=("$1"/*)
|
|
total="${#files[@]}"
|
|
newdir="$(basename "$1")_1080p"
|
|
cmd=(magick '{}' -resize x1080 "$newdir/\$(basename '{}')" '>&2;' echo)
|
|
mkdir -p "$newdir"
|
|
while read -r; do
|
|
echo $((++progress * 100 / total))
|
|
done < <(printf '%s\0' "${files[@]}" | "${XARGS[@]}" "${cmd[*]}")
|
|
}
|
|
|
|
if [ $# = 0 ]; then
|
|
mapfile -t < <(zenity --file-selection --multiple --directory --separator='//' | sed 's // \n g')
|
|
set -- "${MAPFILE[@]}"
|
|
fi
|
|
|
|
for DIR in "$@"; do
|
|
if [ -d "$DIR" ] && [ -x "$DIR" ]; then
|
|
compress "$DIR" | zenity --progress --title="$DIR" --auto-close --time-remaining
|
|
fi
|
|
done
|
|
zenity --info --text=DONE
|