About Hot Folder scripting

Hot folders may be scripted to perform desired actions on incoming files. Possible uses for this ability include integrating third party applications, custom job sorting, or intelligent decision making on how to process jobs.

 

To use scripted hotfolders you need 3 things.

1. your software must be licensed for hotfolder scripting

2. you must check "Process files using Script" in a workflow hotfolder that you wish to run a script in.

3. Some scripting environment.  This can be anything you want to run on the same computer as our Server application.  It could simply be the built-in Windows batch scripting or Powershell scripting.  It could be Python or Perl.  If it's something that isn't built into Windows, you must install it yourself.

 


When this is checked and a script is chosen, the workflow shows that like so:


If the script executes, then a job simply disappears into that script. You might have a workflow that never shows any jobs; but simply scripts them. If you wish the resulting file to re-enter the workflow, have your script deliver it back to the hotfolder. The system will recognize that it has been scripted and then pass it to the next stage of the workflow for processing. Depending on the behavior of the script the input file will either:

  1.  Be moved out of the system, in which case the system will move on to the next file in the hot folder.
  2. Be returned to the hotfolder, in which case the file will be passed to the next workflow action after the hotfolder.
  3. Be renamed in the script, in which case the renamed file should be moved back into the hotfolder for continued processing with the next workflow action.

 

There are variables built-in to our Server's hotfolder scripting function that you can use in your script.

%1   is the full path of the file to process.

%2   is the full path of the script sub-folder of the Hotfolder.



%1 is the path to the file you input to the hotfolder.  AKA this:





Looking at the same picture now we see %2, the scripting subfolder:



The mechanism is this:  When you put a file into the hotfolder, if scripting is checked, then the input file is immediately moved to the scripting subfolder and the script is then executed.

If you want to perform some action on the file and then have it continue in the workflow you submitted it to, then you have to move the resulting file back in with your script.  The folder you need to move it to is one level above the scripting subfolder.

This:


Adding your scripts to the system

 To add more scripts to the list use the “Install Script” menu at the Server.


If your script has support files they must be copied to the Config/Scripts folder inside the Server install folder. Scripts can also be manually copied to this folder.  If you make any changes to the Config\Scripts folder then choose "Refresh Scripts" from the Server menu so we'll reload the contents of that folder.


Example Scripts

Here we will walk through some (.bat) Windows batch scripts that will help you understand how the system works. 

Everything you need to make these scripts work is already in Windows.  You won't need anything additional.


Script 1.  MoveFile.bat

The batch file is attached to this article.  Download it and install it using the instructions above.

Configure it like you see below:


Here are the contents of the script:

What it does is take an incoming file and move it to a folder on the C drive.  If that folder doesn't exist, the script makes it.  When the script is done, your input file is moved and the script completes.  


The input file moves here:


The script, in action:



Script 2.  MoveUp.bat

Hotfolder scripting moves an input file down into the scripting subfolder.  This script simply moves the file back up into the workflow so the file can continue being processed by the next workflow action.  This will show you how to get a file back into the workflow after you have done whatever you need to do.


Script 3. RenamePDF.bat

This script takes a PDF and renames it.  This might be useful if you want to know where the PDF came from or how it was processed or what is intended to be used for.  

It is documented internally (inside the batch file) and also it is documented for the user, here.