Need help with Assets and Orchestrator

I am trying to automate deleting files from WinSCP. I have 10 folder paths where I have to go one by one and delete the text files. I have the automation ready but I am putting it in RefFramework. To do that I assets for each of the 10 folder paths in Orchestrator. But what i want to do is I don’t want to create get asset for each of those asset in UiPath studio. It is because in the future those folder paths could change or add more folder paths and I only want to change it though orchestrator. So how do I get all those assets using only one get asset and have the UiPath studio bring in all the assets I have in Orchestrator without going to UiPath Studio.

Hi @roshan.sapkota

You can do below:

  1. create only 1 asset with all the paths separated by semicolon
  2. fetch the asset.
  3. split the string by semicolon, store in an array
  4. loop through all the folder paths one by one and do the processing.

Alternatively, you can consider creating a JSON text to store folder paths and store json as an asset.

Or you can also consider creating an excel to store all folder paths, read excel and loop though all the paths.

Either way, whenever there is new folder path to be processed, you would simply need to add the path into asset/json/excel to also include the new folder path.

Hope this helps.

Regards
Sonali

Try to use Data Services. It is easy to implement and use in your robot. Most important it is scalable and readable.

Just mention the parent folder in the assets . Parent folder is the folder in which these 10 folders will be present . after getting the Parent folder from the Orchestrator asset use Directory.getDirectories and loop on that. you can run through all the folders with that and again for each folder you can get text files and delete them . Let me know if you need a sample code. cheers

Can you give me a sample code. Thank you!

Hi @Roshan_Sapkota

Can you try this approach and let me know if it works.

  • Create one asset in Orchestrator, say FolderPathsList.
  • Store the paths in this asset as a JSON array:

json

["/folder1/path", "/folder2/path", "/folder3/path"]

In UiPath:

  1. Use a single Get Asset activity for FolderPathsList.
  2. Deserialize the JSON string:
folderList = JsonConvert.DeserializeObject(Of List(Of String))(FolderPathsList)

3.(Use Newtonsoft.Json library — already available in UiPath)*

get Asset : strParentFolderPath

Assign: array_folderPaths = Directory.getDirectories(strParentFolderPath)

for each strfolderPath in array_folderPaths

assign: array_textFilePath = directory.getfiles(strFolderPath,”*.txt”)

for each strTextFilePath in array_textFilePath

delete file = strTextFilePath

let me know if anything needs explanation here :wink: