How to detect Images in a Folder and move them to another folder

Hi @jack.chan and everyone

I have a folder with multiple images (.png) to be specific, I want to detect all images in a folder and move them in a different folder How to do this

The Folder

image

Hi @Ishan_Shelke ,

A combination of Directory.GetFiles() and Move File Activity should be able solve this.

Retrieving all the png files :

pngFiles = Directory.GetFiles("YouFolderPath","*.png")

Here, pngFiles is a variable of type Array of String.

Looping through pngFiles values using For Each Activity and using Move File Activity inside For Each specifying item as the From value and Destination Folder Path as the To Value.
image

Hey!

Try this.

Assign strFolderPath = "Desktop\Input\"
Assign arrFiles = Directory.GetFiles(strFolderPath)

Take one for each activity and pass the arrFiles

Assign strFileName = Path.GetFileName(item)

Now take one if condition and mention the Expression like this

strFileName.ToLower.Contains(".png") or strFileName.ToLower.Contains(".jpg") or strFileName.ToLower.Contains(".jpeg")

In then block use Move File activity

That’s it.

Try this and let me know

Regards,
NaNi

Hi @Ishan_Shelke

Have a look on the XAML file

MoveImagePNG.xaml (6.6 KB)

Regards
Gokul

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.