Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Doing some digging I'm trying to figure out a command line solution for organizing very large archives of images based on their resolution into folders, 1920x1080, 1600x1200, 1600x900, etc.

I've come across a few post on Superuser mentioning something called ImageMagick, is that the best method to the madness I'm trying to accomplish? I've never used any command line functions/applets/tools other then those that come from Microsoft.

I'm rather new to command line usage but ive been enjoying the hell out of it using Powershell, xcopy and robocopy.

I am slowly trying to push myself further into the Linux world with Ubuntu running on one of my physical machines as well as a virtual machine so that's an option as well.

share|improve this question

closed as too broad by Moses, Mokubai, nc4pk, mpy, Dave Nov 14 '13 at 13:00

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

What exactly is the problem? You started out asking something about organizing images based on resolution and then you went off on a tangent about command line languages... – Moses Nov 12 '13 at 16:59
I was trying to get at where my experience level with command-line is as well as state what platforms I use. I figured It would help give a perspective of where I sit knowledge wise. – Anthony Nov 12 '13 at 17:17
Understood, but it would be better to have a little background on your actual problem as well. As this sits, I have no idea what it is you're specifically asking help with. – Moses Nov 12 '13 at 18:51
Specifically I have a very large archive of images, I would like to organize these images into folders using command line based on there resolution 1920x1080, 1600x1200, 1600x900, etc. It'd be nice if I could add a tag associated to there resolution. – Anthony Nov 12 '13 at 19:11
You should probably add that into the body of your question. – Moses Nov 12 '13 at 19:47

Yes, Imagemagick is the way to go. You will need to read the documentation, because it's a very powerful package, but I'll help get you started. The identify command is what you are looking for. Again, look at the docs, but these options will print the file name and resolution on an image (%f prints the file name, %w and %h print the width & height in pixels):

identify -format "%f %wx%h" SampleImage.png

Output: SampleImage.png 1024x1024

If you had a folder full of jpeg images, then you could generate a file with the image name and resolutions of all jpegs with this command (on Windows):

for %i in (*.jpg) do identify -format "%f %wx%h\n" "%i" >> resolutions.txt

The \n is added to force a newline between image names, else everything ends up on one line.

That's just the start. The method you use to group and move them will also be an interesting problem.

Edit: One option you could use to organize the file is to add the resolution to the name. The identify -format can be used to build a batch file to rename the images:

 for %i in (*.jpg) do identify -format "ren ""%f"" ""%wx%h-%f""\n" "%i" >> renImages.cmd

The resulting file content will look like this:

ren "Sample Image.jpg" "1024x1024-Sample Image.jpg"
ren "Sample2.jpg" "1024x512-Sample2.jpg"

Run the renImages.cmd at the prompt to rename all the images, and then you can just sort and group the images however you want.

share|improve this answer
Ok, I'll start looking in that direction. So dose Imagemagick function as a separate software suite where I run a different executable, or is it like xcopy or robocopy where from the standard cmd window i just type the application before my command? Thanks For your Help – Anthony Nov 12 '13 at 19:16
Imagemagick is run from the command line. The installer should put an entry in your PATH variable so that you can run it without referencing a full path to the .exe. It comes with about 18 different programs that perform image manipulation of some sort - resizing, compositing, adding frames, etc. By using these commands in conjunction with the host OS shell language, you can batch process large amounts of images. – Scott McKinney Nov 13 '13 at 15:04

Not the answer you're looking for? Browse other questions tagged .