For Each move files from folder tho another folder

Hello all,
I want to move files from DLV030,E-INV,PL to another folder (other folders don’t move). Please help me. Thank you

Directory.GetFiles(“D:\RPA\UiPath\IPS\Get DFR\Input",”.",SearchOption.AllDirectories).Where(function(s) NOT s.Contains(“xxx”))

@anh.nguyen

can you please explain if you are facing difficulty in anything

also you can directly use for each file in folder activity

cheers

1 Like
  • Create a list of paths and initialize it with the paths to each source folder (DLV03, E-INV and PL)
  • Do a for each loop on this list
    – (For each path) use the activity “For Each File in Folder” by passing the path to the property “In folder”
    – If needed, use the “Filter by” property in the same Activity to select only the files you want to move
    — (For each file) use the activity “Move File”

It will be a loop within a loop.

1 Like

I can directly use for each file in folder activity. But I want to ask can we use 1 for each to move (file in 3folder: DLV030,E-INV,PL) ?

@anh.nguyen

2 options here

if you are deciding which file to move to which folder depending on any criteria then use one loop and if conditions inside to check criteria and change destination folder

or use 3 for loops without any conditions

cheers

1 Like

Ah, you mean something like this?

Directory.GetFiles("your_root_folder", "*", SearchOption.AllDirectories).Where(Function (f) f.Contains("\DLV03\") OrElse f.Contains("\E-INV\") OrElse f.Contains("\PL\")).ToList

Then you do just one loop with the list you get from this operation.

1 Like

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