Extract data from subfolder

Hi All,
I need the bot to iterate through the folder and perform action on each xml present within the subfolder.
example…originalfolder name : Zara
folder structure: Zara\Extractpage\page
within “page” folder there is “test1” i.e. zara\test1 and similarly “test2” folder i.e. zara\test2 and in each of them there can be more than 2 xml files prsent…so i wnat BOT to go through test1 and perform action in the xmls present and then in Test2 folder to perform action in xml present.

Also there can be ‘n’ number of folders present within “page” folder so should should iterate through each subfolder and perform action on its xmls present inside them.

Hey @Zara

I hope you are talking about the Windows Folder.

So you can simply use,

Directory.EnumerateFiles("Zara","*.xml", SearchOption.AllDirectories)

Where,

  • Zara is your parent directory.

  • XML is your filter to search files with type XML

  • SearchOption.AllDirectories is your option to search all the subdirectories of the parent folder

Hope this helps.

Thanks
#nK

but “test1”,“test2” folder names will be coming as input argument from string…trasactionitem.specificcontent(“testdata”).tostring will be having values as {“test1”,“test2”,“test3”} which are folder names and BOT needs to iterate through these folders and perform action on the xmls present in each of these folder

Okay so you know the root path for this ?

Is that constant ?

Why am I asking this is test1 only says folder name where we need the full path to get files.

yeah…root path is constant

Okay great, so inside the root path do we have many folders and a few of which is test1 test2 test3 ?

there can be more than one folder …and each of them will be having xmls

“Data\Extractedtest\zara_Staging_mars_ 030820220322\page” is the root path
and insde page there can be test1, tes2,test3,test4, and inside test1 will be cone.xml,shy.xml …same in test2 and test3

Also these Test1,test2,test3 folder names will be come from queue item name “testdata” having values as {“test1”,“test2”,“test3”}

Okay clear then you can do the following,

TransactionItem.SpecificContent(“testdata”).ToString.Trim.Trim("{}".ToCharArray).Trim.Split(","c)

Use the above in a ForEach

And inside ForEach,

Directory.EnumerateFiles(item,"*.xml", SearchOption.AllDirectories)

You will pass the above in another nested ForEach which will give you each file to do processing on it.

Hope that helps.

Thanks
#nK

can u pls share workflow of this?