This tutorial walks you through a sample Perl script running on a hot folder on a Linux server. You can apply similar concepts to write scripts that run on a Windows Server. In fact, if you install Cygwin on the Windows Server, you could even run a Perl script directly on Windows, if you prefer Perl as the scripting language. But there is no restriction in Zoom on which programming language to use.
- Weed out duplicates in the assets dropped in the Hot Folder. If an asset is a duplicate of a asset already in Zoom, make a smart-copy of the new asset. If an asset is a duplicate of a new asset, not yet ingested, but exists in the Hot Folder, make a smart-copy once the parent asset is ingested.
- Once assets are ingested, launch a pre-defined workflow job from a Zoom workflow template and assign newly ingested assets to the first task
A full copy of the Perl script can be downloaded from here. To add this script to the Hot Folder configuration, you must use the parent BASH Script that executes the Perl script in the Hot Folder pre-script settings.
Line 65: read MD5 checksums of the files that were imported through this hot folder. The checksum is used to test if a file has been ingested or is a duplicate of an existing file in the hot folder
Line 82: Compute the MD5 checksum of the files inside the hot folder or sub-folders within the hot folder.
Line 89: Get the file path of the primordial file with the same checksum.
Line 91: If no matching file path found, then this file is the primordial file, import is directly using the Zoom command line API (CLI) in line 92
Line 97: If there exists a primordial file, then instead of import, use the Zoom smart-copy CLI (fork command) to create a smart-copy of the duplicate file in line 100
Once the files are smart-copied or imported, get the unique asset ID aka FUID for each of the ingested file
The getFuid() perl sub-routine uses the Zoom web API,
/util.jsp?op=getfuid&path=<asset-zoom-path> to convert the file path/names to an asset ID/FUID:
Line 22: Web end-point to invoke to convert each file path to an asset ID.
Line 266: Use Linux curl utility to invoke the web -end point with UTF8 encoded file paths.
Line 135: Invoke the createworkflow CLI with the list of asset IDs to assign to the first task in the job. The various parameters to createworkflow CLI are specified as:
|-c create||Create a new job. -c specified the sub-command name: could be delete or create|
|-s template||Source of the job is a workflow template instead of cloning another job|
|–fuids $csvFuids||Comma separated value list of asset IDs obtained at Line 266 above|
|-wp id=$WF_TMPL_ID||Workflow sub-command parameter is the Template id of the Workflow Template in Zoom to use|
Line 137: If the workflow is successfully launched, log a message to the server’s messages console.