I need to loop through all classification results in Classify Document activity, Save all the classified file results in separate document type folders.
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)
- Get Classification Results: The
Classify Document
activity outputsClassificationResult
(variable type:ClassificationResult[]
). This is an array of all detected document types for the input file. - Loop Through Results: Use a
For Each
activity (TypeArgument:UiPath.IntelligentOCR.Activities.Classification.ClassificationResult
) to iterate through theClassificationResult
array. Let’s say the current item iscurrentClassification
. - 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 inClassify Document
). - To:
Path.Combine("YourOutputFolderPath", currentClassification.DocumentTypeId, Path.GetFileName(LocalResourceFromPath))
.
- From: