#!/usr/bin/env bash

function recursive_optimize_images() {
	cd "$1":

	# Optimize all JPGs and PNGs
	optipng -o6 -strip all *.png;
	jpegoptim --strip-all *.jpg;

	# Optimize all SVGs
	for svg in `ls *.svg`;
	do
		mv $svg $svg.opttmp;
		scour --create-groups \
			--enable-id-stripping \
			--enable-comment-stripping \
			--shorten-ids \
			--remove-metadata \
			--strip-xml-prolog \
			--no-line-breaks  \
			-i $svg.opttmp \
			-o $svg;
	done;

	# Remove temporary SVGs
	rm *.opttmp

	# Check all subfolders
	for dir in `ls -d */`;
	do
			recursive_optimize_images $dir;
			cd ..;
	done;
}

recursive_optimize_images ../

#!/usr/bin/env bash

function recursive_optimize_images() {
	cd "$1":

	# Optimize all JPGs and PNGs
	optipng -o6 -strip all *.png;
	jpegoptim --strip-all *.jpg;

	# Optimize all SVGs
	for svg in *.svg;
	do
		mv $svg $svg.opttmp;
		scour --create-groups \
			--enable-id-stripping \
			--enable-comment-stripping \
			--shorten-ids \
			--remove-metadata \
			--strip-xml-prolog \
			--no-line-breaks  \
			-i $svg.opttmp \
			-o $svg;
	done;

	# Remove temporary SVGs
	rm *.opttmp

	# Check all subfolders
	for dir in */
	do
		if [[ -d "$DIR" ]]; then
			recursive_optimize_images "$dir"
			cd ..
		fi
	done;
}

recursive_optimize_images ../

FIx glob usage to avoid problems with directories that contain spaces
FIx glob usage to avoid problems with directories that contain spaces

Signed-off-by: Joas Schilling <ab43a7c9cb5b2380afc4ddf8b3e2583169b39a02@schilljs.com>
