Skip to main content

Type 3: PowerShell during processing

Enterprise edition and higher

The subfolder templates may not cover complex folder structures. For these cases, BarcodeOCR calls a PowerShell script during processing, but before saving. The script receives all information about the processing, can evaluate it without restrictions and returns the subfolder path and the file name to BarcodeOCR. BarcodeOCR then uses these values when it saves the file.

You set up the interface in the Naming and sorting step of the configuration, with the option Use an external script to define the name of the Subfolder.

Prepare PowerShell

PowerShell scripts must be signed before use, or you first need to adjust the execution policy. If execution is not allowed, an entry appears in the error log and BarcodeOCR does not save the output files in the path you defined. See Prepare PowerShell.

For use cases, such as sorting by recognized text or by a certain text in the barcode, see Use an external script to define the name of the subfolder.

General​

  • BarcodeOCR runs the interface while it prepares saving an output file.
  • The parameters are passed as a data object.
  • BarcodeOCR waits until the script has finished and evaluates the returned values. If the values are not empty, BarcodeOCR uses them for saving.
  • Renaming and duplicate handling defined in the user interface are applied anyway.
  • There is no timeout while waiting for the script.

Parameters​

The interface passes a data object. It can also contain arrays and long texts.

General parameters​

ParameterDescriptionSample values
ConfigurationNameName of the configuration"Test"
ConfigurationGuidUnique identifier of the configurationcbfc4771-7f73-481e-b1ca-e4b95eb3d605
ConfigurationFilePathFile path to the configuration file"C:\ProgramData\Keil IT\BarcodeOCR\AnalyserConfig.xml"
UsedBarcodeRecognized barcode used for splitting and renamingContent of the barcode, empty for error files
ResultWas the file saved in the output folder?True = file saved in the output folder, False = file saved in the error folder
ErrorReasonReason why the document was placed in the error folderNoBarcode, CorruptedFile, Unknown, Duplicate, NameError
FileProcessStartTimeTime when processing of the file started–
SourceFilePathFull path to the input fileC:\Config\dec24748\Tour\Sample.pdf
BackupFilePathFull path to the file in the backup folder (if active)C:\Config\dec24748\Tour\Backup\Sample_eb3d605.pdf
DestinationFilePathFull path to the output fileC:\Config\dec24748\Tour\Error\No_Barcode_1.pdf
SubfolderSubfolder structure, if defined beforehandSubfolder\Sub-Subfolder
NumberOfPagesNumber of pages in the document4
NumberOfRemovedPagesNumber of pages removed by blank page detection0
StartPagePage number of the first page in the original batch1
EndPagePage number of the last page in the original batch4

Parameters per page​

The following information is passed as an array, with one entry per page of the output document.

ParameterDescriptionSample values
NumberPage number4
RecognizedTextRecognized text on this page (if text recognition is enabled)"Lorem ipsum ...."
BarcodesList of recognized barcodes on this pagePer barcode: type, text and X/Y coordinates

Return values​

  • The interface can return two values to BarcodeOCR, which BarcodeOCR takes into account in further processing.
  • The sample script simplifies this step. It offers two corresponding variables that you only need to set.
  • If the script returns empty variables, the values are not overwritten.
  • BarcodeOCR logs the values returned by the script in the process log.
  • If the script throws an error, BarcodeOCR ignores the output of the script and processes the file according to the settings of the configuration.
Return valueDescriptionSample values
SUBFOLDER_NAMEPath of the subfolder structure to be used. BarcodeOCR creates missing folders.Invoices, Invoices/CustomerName/BranchB
FILE_NAMEFile name to be used for the output file. The script can overwrite it.Invoice_VariableFromSQL_Test.pdf