by ssddanbrown · 3y ago · 0 comments
find ./ -type f -iname '*.jpg' -size +1M -print0 | parallel -0 mogrify -format webp -quality 80 {} xargs -n 1 -P 8 #!/usr/bin/env bash
set -e
main() {
if [ "$1" = "handle-file" ]; then
shift
handle-file "$@"
else
find . \
-type f \
-not -path '*/optimized/*' \
-print0 \
| xargs \
-0 \
-L 1 \
-P 8 \
-I {} \
bash -c "cd \"$PWD\" && \"$0\" handle-file \"{}\""
fi
}
handle-file() {
echo "handle-file $1 ..."
}
main "$@"* Grouped output (prevents one process from writing output in the middle of another's output) * In-order output (task a output first, task b output second even though they ran in parallel) * Better handling of special characters * Remote execution
More here: https://www.gnu.org/software/parallel/parallel_alternatives....