Home Image-Pro Automation (Macros, Apps, Reports)
Options

How can I loop through subfolders in a folder?

I would like to have a macro to:

1) Loop through the sub_folders of a main folder
2) Open the frames in the sub_folder in a sequence
2) Stitch the frames
3) Save the tiled Image in Main_Folder, Use the sub_Folder name for the image name
4) Close the tiled image and sequence
5) Go to the next sub_folder

The structure of my files are like this:
Main_Folder ->
...SubFolder1->
......Frame1.jpg
......Frame2.jpg
......Frame3.jpg
.
.
.
......Frame143.jpg
...SubFolder2->
......Frame1.jpg
......Frame2.jpg
......Frame3.jpg
.
.
.
......Frame143.jpg

I was able to do this in ImageProPlus, but I don't know how to do this in ImagePro10. Is this possible in IP10?








Best Answers

  • Options
    Answer ✓
    Hi amirafshar,

    It should be possible in IP 10 as well. First try to figure out your workflow, how you can do it manually (e.g. Load All files from a folder (as a sequence), add them to the Tiling view, set tiling parameters, Create Image, Save...). 
    If that can work repeatedly, you can activate macro recording, do all these steps and check the code. 
    If the tiling of every folder will require different parameters, depending on the context of the folder, then you may need to customize the code to make it flexible.

    You can check our Media Library for tutorials or download free apps from our App Center to use them as examples.

    Yuri

  • Options
    edited August 2021 Answer ✓
    Hi Yuri,

    Thank you for the reply. I did as you mentioned and then added a few lines to customize the code:
    Dim RootPath As String
    Dim oFSO As Object
    Dim Folder As Object
    Dim SubFolders As Object
    Dim SubFolder As Object
    Dim FolderName As String
    
    RootPath = "RootPath\"
    oFSO = CreateObject("Scripting.FileSystemObject")
    Folder = oFSO.GetFolder(RootPath)
    SubFolders = Folder.subfolders
            
    MsgBox "There are " + (SubFolders.Count) + " folders to be processed"
    
    For Each SubFolder In folder.subfolders
    
     FolderName = SubFolder.Name
    code generated by recording the macro
    (Replacing the "RootPath\FolderName\files.jpg with RootPath + FolderName + "\frames.jpg")
    Next SubFolder
    
    oFSO = Nothing
    Folder = Nothing
    SubFolder = Nothing
    This solved my problem.

    Amir

Answers

Sign In or Register to comment.