Skip to content

Instantly share code, notes, and snippets.

@fernandomr
Last active August 3, 2022 12:14
Show Gist options
  • Save fernandomr/c096fb42a51fbcf44201d3bdb8b02242 to your computer and use it in GitHub Desktop.
Save fernandomr/c096fb42a51fbcf44201d3bdb8b02242 to your computer and use it in GitHub Desktop.

Revisions

  1. fernandomr revised this gist Aug 3, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion navigateAndResizeImages.sh
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ for dir in "${arrayOfDirs[@]}"; do
    # fileAbsolutePath=$FOLDER$dotSlash$aux
    # echo "$fileAbsolutePath";
    echo "--processing $aux";
    convert $aux -verbose -resize 620x620 $aux
    convert $aux -verbose -resize $WIDTHx$HEIGHT $aux
    done
    fi

  2. fernandomr created this gist Aug 3, 2022.
    43 changes: 43 additions & 0 deletions navigateAndResizeImages.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    # 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 620x620 $aux
    done
    fi

    cd ..
    done