Announcement

Collapse
No announcement yet.

sorting folders while batch processing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    sorting folders while batch processing

    Hi all

    I have such folder structure:



    Each of the folders (1, 2, 3) contain images. I need to do batch processing for the images resizing them to subfolders and get as result such structure:



    How can I do it with Irfan?

    #2
    Well, as a first impression:
    It's not possible to do this operation in one action-process. Maybe two, or even three.
    0.6180339887
    Rest In Peace, Sam!

    Comment


      #3
      I need to process more 100.000 images, so it can't be done manually, only batch process. I can convert them to separate folder and create the same folder structure ('Create subsolders in destination folder' Irfan's function), but how to implement them in initial structure? That's the question.

      Comment


        #4
        Hi artem-dp,

        To implement the structure, just create the tree 800x600 subdirectories from Windows Explorer.

        Laurent
        Before you post ... fill in your OS and IV version in your profile.

        Comment


          #5
          Hi, Laurent

          You see, it will be very inconvenient for me later to create just one more branch 800x600. I have 3500 folders (in example it is '1' '2' and '3') and I need to convert images from each of them to the corresponding subdirectory: 1\800x600, 2\800x600 and so on. I will transmit this structure to the site and if I add some images to the base I will need to process them on my PC and then just copy to directory on server. And if I operate within the same directory (for example '1') it will be much better because beside 800x600 I need 500x300 and 180x180 folders for thumbnails.

          Artem

          Comment


            #6
            Hi Artem,

            You may combine IrfanView in-line command and batch command file. Here is a suggestion.

            Create two files in your "Images" directory:

            1. a file named "proc_all.bat", copy / paste the following into it, and save it:
            Code:
            for /D %%d in (*.) do proc_one.bat %%d
            2. a file named "Proc_one.bat", copy / paste the following into it, and save it:
            Code:
            cd %1
            mkdir 800x600
            "c:\Program Files\IrfanView\i_view32.exe" %CD%\*.jpg /resize_long=800 /aspectratio /resample /convert=%CD%\800x600\*.jpg
            cd ..
            Running "Proc_all.bat" should visit all subdirectories into your "Images\" folder (that is "Images\1\", "Images\2\", etc.), create into each one a "800x600\" subdirectory (that is "Images\1\800x600\", "Images\2\800x600\") and create into it images resized with a 800 pixels long side. They will have the same name as the original, with the extension .jpg.

            I suggest you to study this code and adapt it to your needs.

            In any case, I strongly encourage you first make a test copy into a dummy "Images\" folder with some subdirectories for test purpose (say 5 folders, with 5 images in each). Then check carefully the results. If needed, do the test with portrait and landscape images, and/or with images having a size ratio not equal to 4:3 (ratio of the desired target images 800x600).

            You were also speaking of 500x300 and 180x180 versions, which don't have a 4:3 ratio. You'll have to decide which real size you want they have (transforming a rectangle into a rectangle with different ratio width:height will create distorsion).

            If everything is ok, then run on the real "Images\" folder.

            These batch commands don't erase anything. But no check or error handling is made.

            If you add new subdirectories into "Images\", or if you add images into existing subdirectories, you will have to create their 800x600 version by hand, or to restart the whole processing. Notice that in this case, if you have removed images, their 800x600 versions will not be removed... I said no check nor error handling.

            Laurent
            Before you post ... fill in your OS and IV version in your profile.

            Comment


              #7
              I created that two files:



              than ran proc_all.bat and got this:



              additionally, new catalog 800x600 created in the root folder:



              I did smth wrong?

              Comment


                #8
                Hi Artem,

                Originally posted by artem-dp View Post
                I did smth wrong?
                The problem I see is that your folders have names containing spaces. You was speaking of folders named "1\", "2\", "3\"
                The consequence is that the first cd command can't reach these folders. That's why the 800x600\ folder is created in the root folder.

                Modify the batch files as follows:
                - in proc_all.bat, enclose the last %%d between double quotes,
                - in proc_one.bat, enclose the %1 (line 1) between double quotes.
                This will avoid the need to rename all your directories

                Laurent
                Before you post ... fill in your OS and IV version in your profile.

                Comment


                  #9
                  Laurent, excellent! Thanks a lot, works great! As I understoond, Irfan uses in this sample its default preferences for jpeg compression, smoothing etc., isn't it?

                  Comment


                    #10
                    How should I change these files if I need to convert images not just with 800 pixels limitation for long side but with such limitations:

                    width:800
                    height:600 ?

                    Comment


                      #11
                      Hi Artem,

                      Look at the help file (Overview | Command Line Options). There are many examples.

                      Laurent
                      Before you post ... fill in your OS and IV version in your profile.

                      Comment


                        #12
                        okey, thank you, Laurent

                        Comment

                        Working...
                        X