# absolute path to image folder FOLDER="" # max width WIDTH=620 # max height HEIGHT=620 cd prods/ # it is array of dirs already arrayOfDirs=(*/) # loop trough dirs for dir in "${arrayOfDirs[@]}"; do echo "entering $dir"; cd $dir; # FOLDER=$(pwd); # get files bigger than 640kb arqs=( $(find ./ -maxdepth 1 -type f -size +640k) ) numOfFiles=${#arqs[@]} # echo "num of files: $numOfFiles" if [ $numOfFiles > 0 ]; then for fileItem in ${arqs}; do # echo "$fileItem"; # mount file absolute path aux=${fileItem##*/} # fileItem is in format "./2938230982309823.png". This cuts after './' dotSlash="/" # fileAbsolutePath=$FOLDER$dotSlash$aux # echo "$fileAbsolutePath"; echo "--processing $aux"; convert $aux -verbose -resize $WIDTHx$HEIGHT $aux done fi cd .. done