Writing file names to excel after classification

Hi team,

I am currently working on scenario where I want to classify relevant and irrelevant files and then copying the classified and unclassified files to the relevant folders. After copying I want to write those classified files to the excel workbook on Sheet1 with relevant files and on sheet2 with irrelevant files.

I have successfully copied the relevant and irrelevant files to the respective folders. But when I try to write files on excel sheet it doesn’t properly get written into excel file.

Any help in this regard will be highly appreciated.
Regards
Enthusiastic

Hi @enthusiastic,

For the part where you need to pick file names from specific folders and write into excel file.

You can simply use like
docPaths=Directory.GetFiles(“folder path goes here”), this will give you all files along with their path.

Then run a for loop on same docPaths fetched in above statement, and inside loop
System.IO.Path.GetFileNameWithoutExtension(filepath)
or
System.IO.Path.GetFileName(filepath)

And then write the same into excel file.

Regards
Sonali

I dnt want to write the files names from the current folders where files are copying. I want to write the root directory path. I have already used these activities in my workflow. The issue is that after classification I am using If condition with the output of classification variable like this “classification.any()” in then condition I am copying and then writing the files to excel sheet. same as with the else condition where I am writing and copying irrelevant files. But the When I open the excel sheet the results did not match with the files copied in the folders after classification.

Hi @enthusiastic,

So, what are the results like, is the path like one level up or down or its totally different from the one you want to update?

Regards
Sonali

Hi @sonaliaggarwal47 paths are totally different. I want to write path of root directory in excel file. But when I am doing so, it prints irrelevant file name in relevant sheet and duplicates and write multiple file names in irrelevant sheet of excel workbook. Workflow is not writing correct values to excel sheet.