I am trying to use uipath to place a file in multiple sub-folders within multiple folder while excluding certain folders. I have managed to get UIpath to a folder that contains 5 folders. Well call them Mainfolder 1, Mainfolder 2, Mainfolder 3, Mainfolder 4, and Mainfolder 5. I want to exclude Mainfolder 1 and 5. Within each of the other Mainfolders are various amounts of subfolders. I need to place this file within each of these subfolders. Any ideas on how to do this?
In your For Each loop through the directories -
Add an if at the start to see whether folder path is should be ignored or not but doing string comparison.
Hi, welcome to uipath community forum
use for each loop
For each of Directory.getdirectories(“Mainfolderpath”)
Change the for each loop argument to string
Now use of condition
If
Item.contains(“Mainfolder1”) or Item.contains(“Mainfolder5”)
Then
Use continue activity
Else
Use another for each loop
For.each of Directory.getdirectories(item)
Change the for each loop argument property to string
Now inside this for each loop
Use copy file activity
At source property give the target file.path
And at destination property give value as ‘item’
Those solutions helped but I am now running into two issues. First, it is also placing a file in the Main folders not just the sub-folders. Second, it is only placing a file in sub-folders if it has a sub-folder in it.
Hi , that could be because of item is same for 2 loops as those are nested loops
What you can do here is
Pls modify as stated below for my solution in my previous comment
At the 2nd for each loop
Instead of keeping it as item , change it to folder
Just rename from item to folder
For each folder Directory.getdirectories(item)
Now inside body of loop
Use move file with destination property value as ‘folder’