How to seperate classification results and save classified files in separate document type folders?

I need to loop through all classification results in Classify Document activity, Save all the classified file results in separate document type folders.

Hi @Sreekar_Mulinti

you can loop through the classification results to get each document type and its page range. For each result, split the original file using the page range, then create a folder named after the document type (like Invoices or Receipts). Save the split file into that folder. If any pages are unclassified, save them in a separate folder called Unclassified

For more:

Appreciate if you can provide an example scenario in xaml file. I’m using only UiPath document understanding activities (Classify Document Activity)

  1. Get Classification Results: The Classify Document activity outputs ClassificationResult (variable type: ClassificationResult[]). This is an array of all detected document types for the input file.
  2. Loop Through Results: Use a For Each activity (TypeArgument: UiPath.IntelligentOCR.Activities.Classification.ClassificationResult) to iterate through the ClassificationResult array. Let’s say the current item is currentClassification.
  3. Create Folder & Move File:
  • Inside the loop, get the document type name: currentClassification.DocumentTypeId.
  • Use Create Folder (if it doesn’t exist): Path.Combine("YourOutputFolderPath", currentClassification.DocumentTypeId)
  • Use Move File to move the original classified file into this new folder:
    • From: LocalResourceFromPath (the original input file path used in Classify Document).
    • To: Path.Combine("YourOutputFolderPath", currentClassification.DocumentTypeId, Path.GetFileName(LocalResourceFromPath)).