25 November 2014

Distribute Image Based on Size using Bash Script

Taken from https://superuser.com/questions/17562/how-to-sort-images-into-folders-based-on-resolution/591490#591490

  • Create this script on the directory of the Images
  • Save the script as (for example) scriptdistribute.sh
  • chmod a+x scriptdistribute.sh
  • Run the script ./scriptdistribute.sh


#!/bin/bash

for image in *.jpg *.JPG *.jpeg *.JPEG *.gif *.GIF *.bmp *.BMP *.png *.PNG;
    do res=$(identify -format %wx%h\\n "$image");
    mkdir -p $res;
    mv "$image" $res;
done

No comments:

Post a Comment