Running Post-Process Commands with Watch Folder Service


Introduced in Document Conversion Service 3.0.010, the Watch Folder Service can now run post-process commands for each file it finds to convert. These commands can be batch files or other executables.

You can specify separate commands to run  when the conversion succeeds and when it fails.

When the conversion is successful, we run the command against each file created by the conversion. If the conversion fails, then we run the command against the original source file.

A sample scenario of how this could be useful would be a watched folder set up to run a command to upload all newly converted files to an FTP server or a web server when they are successfully converted, and to send an email with the name of the original file in the case of a conversion failing.

Command Window Mode

The default behaviour is to run the command in a Hidden window. We recommend setting the window state to Normal when you first add in a success or failure command until you have confirmed the command is working and that you are passing your arguments expected.

  • Hidden – do not show the window. (Default)
  • Normal – display the window in its normal state.
  • Min – display the window minimized to the taskbar
  • Max – display the window maximized.

Waiting for a Command to Finish

When running a command, the Watch Folder will either wait for the command to complete or not wait for it to complete and will move on to the next file immediately. The default action is not to wait for the command to complete.

When waiting for the command to complete, a maximum wait time controls when to stop the running command if it has not completed in a timely fashion. This timeout can be increased but it cannot be set to 0 and it is enforced. The default timeout is three minutes.

  • DoNotWait – does not wait for the command to complete. (Default)
  • WaitForCompletion – wait for the command to complete before continuing.
  • WaitWithExitCode – waits for the command to complete and emits the exit code in the log.

Passing Arguments to Your Commands

The following variables for are available to use in your command line parameters. These variables will be automatically replaced with their appropriate values when the command runs.

  • $(OutputFilePath) – this is the path to the converted file.
  • $(FailedFilePath) – this is the path to the original file in its failed location.
  • $(SourceFileName) – this is the file name of the original file.

Testing Command Lines.

The default settings are to run the command with the window mode Hidden and the wait mode set to DoNotWait for the command to complete before moving on to the next file.

When adding and testing new commands we recommend setting the window state to Normal and the wait mode to WaitForCompletion until you have confirmed the command is working and your arguments are being passed as expected.

Sample Usage

Below is a sample post-conversion setup using the fictional command line tools UploadToServer.exe and TriggerEmailFail.exe. These executable names are placeholders that you would replace with your own command line tools that fit your workflow. They are not part of Document Conversion Service.

Take note of the usage of HTML escape characters for the quotation marks around the variable names in the parameters in order to pass the parameters with enclosing quotes.

Running a Command on Success:



Running a Command on Failure:


Getting Help and Other Features

Command won’t run or not sure why it isn’t working? Are you looking for a feature that you don’t see here? Contact us and we’ll be glad to help.

Here are some other features of Watch Folder Service you might be interested in: