Background: I've got a folder full of saved desktop pictures. I'd like to put them into folders, based on their resolution - 1024x768, etc. Creating the folders on the fly is a bonus. Currently, the images are all in a folder, but some of them are in sub-folders. I can merge them by hand, if that makes things easier.

I'd prefer the terminal, though I'm still kind of a bash newbie. I'm not much of a programmer at all, really.

I'm using Mac OS X, but I'm not opposed to installing extra apps to accomplish this (MacPorts?), or even using another OS (I've got Windows XP, Windows Vista, and Ubuntu 9 setup right now within VMWare).

6 Answers 6


I know it's an over a year topic (sorry about that) but i think someone may need the full working script, so here it is. Taking the ideas here and compiling into a script we get.


for image in *.jpg;
    do res=$(identify -format %wx%h\\n $image);
    mkdir -p $res;
    mv $image $res;

Seriously, thanks for replying, everyone! I've come back to this, more experienced, and most of the comments here make more sense now.

I tweaked @zatatlan's script slightly to accommodate spaces in filenames and to add more file extensions.


shopt -s nullglob # The script spits errors if this is not set and there are, say, no *.png files.
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;

It is possible to use imagemagick to detect image resolution. Wrap it in a bash loop and there you go. I won't wait until I get home to a bash shell, so here is something off top of my head. The syntax is probably wrong, but it might give you some clues.

for image in $(`*.jpg`) do
   res=`identify $image | grep -o 'Resolution:'`
   if [ ! -d $res ]; then
     mkdir $res

   mv $image $res

The script creates directories on the fly. Both bash and imagemagick are available for mac.

  • You can make the script a bit shorter and simpler by replacing the if block with a simple mkdir -p $res. Nov 7, 2009 at 21:58

There is Amok EXIF Sorter

AmoK Exif Sorter can rename pictures, and move or copy them to arbitrary folders.
The folders can be named according to the exif data.

Offers a live preview of the file names, an integrated picture and exif data viewer, drag & drop, thumbnail view, automatic update check, and profiles for different cameras and users.

Also supports Video files by creation date, IPTC formatted files.

Written in JAVA, works on all platforms supporting JRE5.
Checkout the feature list on the link.

Don't get discouraged by the German language.
Pull down Sprache and select Englisch, restart the application.


The ImageMagick identify command can give you the width and height in pixels, e.g.

~$ identify -format %w_%h\\n *jpg 

You can put that into a bash script as part of a for loop and, for safety, copy the files into a directory that is named the same as the resolution (check if it exists and create if not).


A basic way that will give a rough order of resolution is to organize by file size. This is something that should be built into any OS, so you don't need anything special. The BIG catch with this is that the format for your photos would need to be the same for this to work. This isn't a perfect solution, but it may be an easy stop-gap until you find something that actually fits the bill.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.