i have an excel with list of ID’S .ID Ex: 2142263454,2347752329. Always the length of ID will be 10. After pcking the ID from excel i ahve to pick a file from the folder where the folder contains n number of files.
File format: 2142263454_XXXXXX_439457398573959809
the thing is how to check the file exists or not in the folder based on ID?
@avinashy You will have to get all the files using Directory.Getfiles(“Path”).
Then, loop through the file names and check if that file contains this string,
- Use a “Read Range” activity to get the list of ID’s as a Datatable (considering the IDs are different cells in the same column).
- Use a “For Each Row” loop. Set the value of the Datatable property to the Datatable variable where you just extracted the IDs from excel in step 1.
- Inside this loop, use a “For Each” loop. In the “Values” property, type in Directory.GetFiles(“Path_to_folder”). Here, put the path of the folder containing the files. e.g. “D:\Documents\Folder_of_files” as the argument. Set TypeArgument property to String.
- In this loop, use a “If” activity. The condition should be item.Split("_"c)(2) = row.Item(0).ToString.
Now you can do what you need inside the “Then” branch. Happy coding.
If you can build the path, then use “Path Exists” and select the Path Type to be “File”, the result will be a boolean.
@avinashy Were you able to do this?
If yes, just mark the appropriate reply as solution and close this thread.
If no, let us know your further queries.