Folder with images

Hello i have a folder with 4-6 images with specific names

I want a proccess that loops through all the images in that folder and assign those images to variables, its important that it dont miss out any of the selected images.

1 Like

Hi
Hope these steps would help you resolve this
—use a assign activity and mention like this
arr_filepath = Directory.GetFiles(“yourfolderpath”)

Where arr_filepath is a variable of type array of string

—now use a FOR EACH activity and pass the above variable as input and change the type argument as string
—inside the loop use LOAD IMAGE activity and pass the input as item.ToString and we can get the output as a image variable

Cheers @langsem

1 - ArrayStr=Directory.GetFiles(FolderPath)
2 - For each loop of Argument type is String
3 - if you print item.tostring you will get image paths
4 - now you can assign to your own variables

GetFileNames.xaml (6.3 KB)
tried this
is this what you are looking for let me know if it’s working or not.
cheers @langsem

yes know. Only problem its that the image are in mixed order. I have to look the images up by name and then assign the image to correct variable. Lets say image a are in row 2 then i cant assign image a to var a because its not in correct order.

its almost, only here it takes the first image it can find. I need to combine specific images to specific variables

Did this steps help us

Cheers @langsem

Almost, same issue there i am afraid :confused:

Its not always that the image 1 its there and also it can be the 6th image in the order sometimes. Only thing that dont change its the name of the images.

1 Like

So if you want to sort the file name then in the
Then in assign activity mention like this
arr_filepath = Directory.GetFiles(“yourfolderpath”).AsEnumerable().OrderBy(Function(a) a.ToString).ToArray()

Cheers @langsem

here ?

No, dont want to sort the filename.

But want to assign variables to speicifc images based on the images name

1 Like

Like the variable name must be Filename
Is it so
@langsem

so you want to create a variables for every image??

Yes want to create a variable for every image because later on i would need to upload each image to a server and it needs to be correct images.

So like image named “Bilde_av_glassets_id” needs to be assigned to a variable called Image_GlassID

then for another image “Bilde_av_ruten” assigned to Image_Windscreen - then so on

1 Like

To do this I hope we don’t need to keep the same name of file as variable name as we are any how going to process the images obtained as variable one by one within the loop and that will work more faster and easier to process as well
Cheers @langsem

what you mean ?

If you already know the file names, why dont you just use Load Image activity?

Hm, will try. It then assigns to a variable ?

Yes, this is what that activity does… get an image from your disk and assigns to a variable you choose…

I assume you need to use specific picture in specific part of your process…

You could store your images in a dictionary(string,image)


where
string will be the the file name (e.g. “Bilde_av_glassets_id”)
image will be the image itself

Later in the process you could get the image value like
img_var = dicImages("Bilde_av_glassets_id")

Cheers