Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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).

Any help would be appreciated! Thank you!

share|improve this question

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.

#!/bin/bash

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

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
   fi

   mv $image $res
done

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

share|improve this answer
    
You can make the script a bit shorter and simpler by replacing the if block with a simple mkdir -p $res. –  Ryan Thompson Nov 7 '09 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.

share|improve this answer

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

~$ identify -format %w_%h\\n *jpg 
2868_3429
1056_960

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).

share|improve this answer

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.

share|improve this answer
up vote 0 down vote accepted

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.

#!/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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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