How to sort images into folders, based on resolution?












8














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





























    8














    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



























      8












      8








      8


      4





      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















      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!







      images resolution sorting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 3 '09 at 12:14









      nik

      48.3k886132




      48.3k886132










      asked Aug 3 '09 at 11:55









      flammable

      8117




      8117






















          6 Answers
          6






          active

          oldest

          votes


















          10














          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





























            4














            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

            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;
            done





            share|improve this answer































              3














              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



















              2














              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































                1














                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





























                  0














                  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





















                    Your Answer








                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "3"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    autoActivateHeartbeat: false,
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f17562%2fhow-to-sort-images-into-folders-based-on-resolution%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    6 Answers
                    6






                    active

                    oldest

                    votes








                    6 Answers
                    6






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    10














                    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


























                      10














                      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
























                        10












                        10








                        10






                        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












                        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












                        share|improve this answer



                        share|improve this answer










                        answered Nov 13 '10 at 19:34









                        zatatlan

                        10112




                        10112

























                            4














                            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

                            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;
                            done





                            share|improve this answer




























                              4














                              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

                              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;
                              done





                              share|improve this answer


























                                4












                                4








                                4






                                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

                                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;
                                done





                                share|improve this answer














                                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

                                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;
                                done






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Dec 7 at 16:10









                                HappyFace

                                1289




                                1289










                                answered May 4 '13 at 17:27









                                flammable

                                8117




                                8117























                                    3














                                    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
















                                    3














                                    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














                                    3












                                    3








                                    3






                                    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












                                    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












                                    share|improve this answer



                                    share|improve this answer










                                    answered Aug 3 '09 at 12:08









                                    user4126

                                    54636




                                    54636












                                    • 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


















                                    • 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
















                                    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




                                    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











                                    2














                                    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




























                                      2














                                      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


























                                        2












                                        2








                                        2






                                        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














                                        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














                                        share|improve this answer



                                        share|improve this answer








                                        edited Aug 8 '09 at 8:47

























                                        answered Aug 3 '09 at 12:16









                                        nik

                                        48.3k886132




                                        48.3k886132























                                            1














                                            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


























                                              1














                                              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
























                                                1












                                                1








                                                1






                                                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












                                                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












                                                share|improve this answer



                                                share|improve this answer










                                                answered Aug 3 '09 at 12:13









                                                mas

                                                2,4111727




                                                2,4111727























                                                    0














                                                    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


























                                                      0














                                                      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
























                                                        0












                                                        0








                                                        0






                                                        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












                                                        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












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Aug 3 '09 at 12:25









                                                        DHayes

                                                        2,0631016




                                                        2,0631016






























                                                            draft saved

                                                            draft discarded




















































                                                            Thanks for contributing an answer to Super User!


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.





                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                            Please pay close attention to the following guidance:


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.




                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function () {
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f17562%2fhow-to-sort-images-into-folders-based-on-resolution%23new-answer', 'question_page');
                                                            }
                                                            );

                                                            Post as a guest















                                                            Required, but never shown





















































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown

































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown







                                                            Popular posts from this blog

                                                            Plaza Victoria

                                                            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                                                            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...