Starting with Document Conversion Service 3.0.010, the Watch Folder Service now includes the ability run a separate command in the success and failure cases at the end of conversion.

For version 3.0.010, if the conversion is successful, the command is run for each file created by the conversion. This means that if you are creating serialized files, the command will be run for every file created. If the conversion fails, the command for the failed scenario is run on the original source file.

This was updated in version 3.0.015 so that the commands are not run until the successfully created files are copied into the output folder, or for the failure case, when the original source file is copied into the failed folder. Also, the default behavior for the success command has been changed to only run the command a single time, instead of once for each file. A new parameter has been added that allows you to change this back so that the command is run for each file.

Also new with version 3.0.015 is a parameter to enable the creation of a text file containing a list of all of the files created. This file is created in the watched folders's OutputFolder location. it is named using the source file name, a random suffix and ends with the extension .wfsoutputlist. You are responsible for deleting this file when you are done with it.

Macros for the source file name, the output list, the number of files created, and other information is available to use in your command line parameters to pass this information into your command. There are different macros for the Success and Failed options; a full list is provided below.

The defaults for running a command are not to wait for the command to complete before continuing. If you do need to wait for the command to be completed, this can be changed, and there is a maximum timeout value that must be specified to allow the process to move ahead if the command does something unexpected.

Shown below are sample post-conversion options to process the created files as a group, or to process each file individually. They use the fictional command line tools BatchUploadToServer.exe, UploadToServer.exe and TriggerEmailFail.exe. These executable names are placeholders that you would replace with your own command line tools that fit your workflow. Thes command line tools are not part of Document Conversion Service.

See the table below for a full description of each setting.

Code Sample - Sample Post Conversion Commands - Run Once on Success/Fail

 

<WatchFolders>
 
  <!-- This watch folder creates 300 DPI Optimized TIFF Images -->
  <WatchFolder Name="ConvertToTIFF Watch Folder">
    <Settings>
      <!-- Folder options -->

      ...
        
      <!-- Run Command at End On Success -->

      <!-- Run the command once, passing in the list of created files -->

      <!-- and the original source file. -->

      <add Name="RunAtEnd.Success.Enabled" Value="true" />

      <add Name="RunAtEnd.Success.Command" Value="C:\MyTools\BatchUploadToServer.exe" />

      <add Name="RunAtEnd.Success.RunForEachFile" Value="false" />

      <add Name="RunAtEnd.Success.CreateOutputFileList" Value="true" />

      <add Name="RunAtEnd.Success.Parameters"

           Value="&quot;$(OutputFileList)&quot; &quot;$(SourceFileName)&quot;" />

      <add Name="RunAtEnd.Success.StartDirectory" Value="" />

      <!-- ** Internal Use Only ** - One of Normal, Min, Max, Hidden (default) -->

      <add Name="RunAtEnd.Success.WindowState" Value="Hidden" />

      <!-- Wait mode for the command, one of WaitForCompletion, WaitWithExitCode, DoNotWait (default)-->

      <add Name="RunAtEnd.Success.WaitMode" Value="DoNotWait" />

      <!-- Default is 3 minutes -->

      <add Name="RunAtEnd.Success.WaitModeMaxTime" Value="180000" />

 

      <!-- Run Command at End On Failure -->

      <!-- If a file fails to convert, send an email with the path to the failed file.-->
      <add Name="RunAtEnd.Fail.Enabled" Value="true" />

      <add Name="RunAtEnd.Fail.Command" Value="C:\MyTools\TriggerFailEmail.exe" />

      <add Name="RunAtEnd.Fail.Parameters"

           Value="&quot;$(FailedFilePath)&quot; &quot;$(SourceFileName)&quot;" />

      <add Name="RunAtEnd.Fail.StartDirectory" Value="" />

      <!-- ** Internal Use Only ** - One of Normal, Min, Max, Hidden (default) -->

      <add Name="RunAtEnd.Fail.WindowState" Value="Hidden" />

      <!-- Wait mode for the command, one of WaitForCompletion, WaitWithExitCode, DoNotWait (default)-->

      <add Name="RunAtEnd.Fail.WaitMode" Value="DoNotWait" />

      <!-- Default is 3 minutes -->

      <add Name="RunAtEnd.Fail.WaitModeMaxTime" Value="180000" />

      ...
        
    </Settings>
  </WatchFolder>
</WatchFolders>

 

 

Code Sample - Sample Post Conversion Commands - Run for Each File on Success/Once on Fail

 

<WatchFolders>
 
  <!-- This watch folder creates 300 DPI Optimized TIFF Images -->
  <WatchFolder Name="ConvertToTIFF Watch Folder">
    <Settings>
      <!-- Folder options -->

      ...
          
      <!-- Run Command at End On Success -->

 

      <!-- Run the command for each file created, passing in the created file name -->

      <!-- and the original source file. For serialized output this command is run multiple times.-->

      <add Name="RunAtEnd.Success.Enabled" Value="true" />

      <add Name="RunAtEnd.Success.Command" Value="C:\MyTools\UploadToServer.exe" />

      <add Name="RunAtEnd.Success.RunForEachFile" Value="true" />

      <add Name="RunAtEnd.Success.CreateOutputFileList" Value="false" />

      <add Name="RunAtEnd.Success.Parameters"

           Value="&quot;$(OutputFilePath)&quot; $(OutputFileNumber) $(OutputFileNumberCount)" />

      <add Name="RunAtEnd.Success.StartDirectory" Value="" />

      <!-- ** Internal Use Only ** - One of Normal, Min, Max, Hidden (default) -->

      <add Name="RunAtEnd.Success.WindowState" Value="Hidden" />

      <!-- Wait mode for the command, one of WaitForCompletion, WaitWithExitCode, DoNotWait (default)-->

      <add Name="RunAtEnd.Success.WaitMode" Value="DoNotWait" />

      <!-- Default is 3 minutes -->

      <add Name="RunAtEnd.Success.WaitModeMaxTime" Value="180000" />

 

      <!-- Run Command at End On Failure -->

      <!-- If a file fails to convert, send an email with the path to the failed file.-->
      <add Name="RunAtEnd.Fail.Enabled" Value="true" />

      <add Name="RunAtEnd.Fail.Command" Value="C:\MyTools\TriggerFailEmail.exe" />

      <add Name="RunAtEnd.Fail.Parameters"

           Value="&quot;$(FailedFilePath)&quot; &quot;$(SourceFileName)&quot;" />

      <add Name="RunAtEnd.Fail.StartDirectory" Value="" />

      <!-- ** Internal Use Only ** - One of Normal, Min, Max, Hidden (default)-->

      <add Name="RunAtEnd.Fail.WindowState" Value="Hidden" />

      <!-- Wait mode for the command, one of WaitForCompletion, WaitWithExitCode, DoNotWait (default)-->

      <add Name="RunAtEnd.Fail.WaitMode" Value="DoNotWait" />

      <!-- Default is 3 minutes -->

      <add Name="RunAtEnd.Fail.WaitModeMaxTime" Value="180000" />

      ...
        
    </Settings>
  </WatchFolder>
</WatchFolders>

 

RunAtEnd Success Commands:

Key

Value

RunAtEnd.Success.Enabled

Set this to true to run the specified command when conversion succeeds.

 

Starting with version 3.0.015 the default is to run the command ONCE at the end of conversion, when all the files have been created. This means that even when you are creating serialized output, the command is only called once.

 

To run the command for EACH FILE created, set RunAtEnd.Success.RunForEachFile to true. This matches the original behavior from version 3.0.010 when the run commands were first introduced.

RunAtEnd.Success.RunForEachFile

Introduced in version 3.0.015.

 

The default for this is false, meaning the command will only be run a single time when conversion succeeds and all output files are successfully copied into the Output folder.

 

Change this value to true to return to the original behavior of running the command for each file created from version 3.0.010. This means the command can be run multiple times when creating serialized output.

RunAtEnd.Success.CreateOutputFileList

Introduced in version 3.0.015.

 

Setting this value to true will create a Unicode text file that lists all files created. This file is created in the OutputFolder location and is named based on the source file name, a random suffix and the extension .wfsoutputlist. Use the variable $(OutputFileList) to pass the file name to your command.

 

You are responsible for deleting this file when you are done with it.

RunAtEnd.Success.Command

The full path to the command to be executed without arguments. Default is an empty string, no command to run.

RunAtEnd.Success.Parameters

The parameters for the command. Use the HTML code " to put the command in quotes if there are spaces, and to enclose parameters. The following variables are available to pass arguments to the command.

 

$(OutputFilePath) -  this is the full path to the converted file. Beginning with version 3.0.015 , when creating serialized output this is the last file created in the set unless RunAtEnd.Success.RunForEachFile is true, in which case it is the full path to the converted file.

$(SourceFileName) - this is the file name of the original file.

 

Introduced in version 3.0.015:

$(OutputFileList)  - valid when RunAtEnd.Success.CreateOutputFileList is set to true, this variable is the full path to a Unicode text file containing a list of all the files created, one per line. This list can be a single file, for multipaged conversion, or many files in the case of serialized conversion. See the parameter for more information.

$(OutputFileNumber) - this is the numerical index of the file being processed in the run command. Index starts at 1.

$(OutputFileNumberCount) - this is the number of files created, not including any text extraction files.

 

RunAtEnd.Success.StartDirectory

The directory in which to run the command. Default is an empty string.

RunAtEnd.Success.WindowState

This option is for internal use only; we recommend leaving this set to the default of Hidden.

 

The view state of the command window when it is run.

 

Normal - display the window in its normal state.

Min - display the window minimized to the taskbar

Max - display the window maximized.

Hidden  - do not show the window. (Default)

RunAtEnd.Success.WaitMode

Optionally wait for the command to complete before continuing. The default is to not wait.

 

If WaitForCompletion or WaitWithExitCode is chosen, the RunAtEnd.Success.WaitModeMaxTime value is always used to stop the command if it has not returned after the set amount of time.

 

WaitForCompletion - wait for the command to complete before continuing.

WaitWithExitCode - waits for the command to complete and emits the exit code in the log.

DoNotWait - does not wait for the command to complete. (Default)

RunAtEnd.Success.WaitModeMaxTime

The maximum amount of time to wait for the command being run to complete. Default is 3 minutes.

 

RunAtEnd Fail Commands:

Key

Value

RunAtEnd.Fail.Enabled

Set this to true to run the specified command on the original file if the conversion fails. Default is false.

RunAtEnd.Fail.Command

The full path to the command to be executed without arguments. Default is an empty string, no command to run.

RunAtEnd.Fail.Parameters

The parameters for the command. Use the HTML code " to put the command in quotes if there are spaces, and to enclose parameters. The following variables are available to pass arguments to the command.

 

$(FailedFilePath) -  this is the path to the original file in its failed location.

$(SourceFileName) - this is the file name of the original file.

RunAtEnd.Fail.StartDirectory

The directory in which to run the command. Default is an empty string.

RunAtEnd.Fail.WindowState

This option is for internal use only; we recommend leaving this set to the default of Hidden.

 

The view state of the command window when it is run.

 

Normal - display the window in its normal state.

Min - display the window minimized to the taskbar

Max - display the window maximized.

Hidden  - do not show the window. (Default)

RunAtEnd.Fail.WaitMode

Optionally wait for the command to complete before continuing. The default is to not wait.

 

If WaitForCompletion or WaitWithExitCode is chosen, the RunAtEnd.Fail.WaitModeMaxTime value is always used to stop the command if it has not returned after the set amount of time.

 

WaitForCompletion - wait for the command to complete before continuing.

WaitWithExitCode - waits for the command to complete and emits the exit code in the log.

DoNotWait - does not wait for the command to complete. (Default)

RunAtEnd.Fail.WaitModeMaxTime

The maximum amount of time to wait for the command being run to complete. Default is 3 minutes.