Tips and tricks

TinyPNG CLI setup to compress all files in a folder
Posted on January 1 2020
This has only been tested on mac but should run on LINUX and WINDOWS ( power shell ) as well. We will have to create a file in your folder called minify.command
Declare array of files we will ignore ( already compressed files ) and we will transform
declare -a exclude_array declare -a compress_array
move to your folder, and scan files
STR="`dirname $0`"
cd $STR
yourfilenames=`ls .`
for eachfile in $yourfilenames
do
if [[ "$eachfile" == *"compressed"* ]]
then
echo $eachfile
dup=${eachfile/compressed}
exclude_array+=($eachfile)
exclude_array+=($dup)
fi
done
for eachfile in $yourfilenames
do
if [[ "$eachfile" == *".png"* ]] || [[ "$eachfile" == *".jpg"* ]] ; then
echo $eachfile
compress_array+=($eachfile)
fi
done
now that we have the files and we make sure we will that we rename so that we won’t compress again redundantly
for target in "${exclude_array[@]}"; do
for i in "${!compress_array[@]}"; do
if [[ ${compress_array[i]} = $target ]]; then
unset 'compress_array[i]'
fi
done
done
for target in "${compress_array[@]}"; do
tinypng $target
mv $target compressed-${target}
done
AUTHOR
Setup a .babelrc in your user directory
Get Browserify Globally as Watcher in PhpStorm [ add Babelify ] !