Looping through files in a folder

Hello RPA legends. I’m looking to create a sequence that loops through all the files in a folder and extract any .txt files and move them to a folder on an FTP.

Any tips would be greatly appreciated.

Thanks!

@Gavin_Mcmaster

Assign, str[] files = Directory.getFiles(“Folderpath”,"*.txt")

Above expression will give all .txt files in a folder and then use For each activity to iterate it and use Move File activity to move files.

1 Like

@Gavin_Mcmaster After downloading zip file from Here change .doc to .txt and use move file activity

1 Like

@lakshman Can you please send me a screenshot? I can’t get the assign to work.

@Gavin_Mcmaster

Please check below screenshot.

Here, str variable is of type string array.

Thanks. Can you spot what I’ve done wrong? What is the variable type?

Capture

Capture2

@Gavin_Mcmaster

I said to create string array variable but you created string variable. please check below.

2 Likes

Hi @Gavin_Mcmaster

Your requirement can implement in very easy way.

Reference my process attached below.

Beware my variable type!
image

Don’t forget to mark as solution if this one can help you.

Thanks,

Sequence1.xaml (8.7 KB)

Ah, sorry. I didn’t see your comment below the image. :man_facepalming:

@Gavin_Mcmaster

Ok. No problem. Is the issue resolved now or not ?

If you face any issues then please let me know.

1 Like

Sorry, still not working…

Directory Get Files.xaml (6.6 KB)

@Gavin_Mcmaster

I checked your workflow and found some mistakes.

  1. For each activity, you did not change the type argument. By default, It would be string and we have to change it according to our variable type. Here, It should be string

image

  1. And also you passed full path in From property of Move File activity and change it to item here. Because the file path is stored in item variable here.

Please find the attached workflow.

Directory Get Files.xaml (5.8 KB)

2 Likes

Thanks @lakshman

1 Like

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