EasyMorph can run external applications and Windows shell commands either once or multiple times in a loop. Most frequently this is used for file manipulations (copying, renaming, unzipping, etc.) or integration with 3rd party applications.
The "Run program" action starts specified external application with command-line arguments (if required), and waits until it finishes.
The command line arguments for the application can be specified either as a constant line of text, or using an expression. In the latter case, the expression can use project parameters (but not field names).
Hint: Wrap file names in double quotes in command line expressions as they may contain spaces.
If application is not specified (the application path is empty) then "Run program" executes the command line as a Windows shell command. The example below shows using "Run program" for copying a file.
A common use case for "Run program" is reusable projects for file operations. In the example above the old file location and the new location are specified by parameters. Now, if we save this project as, say, file_copy.morph we obtain a reusable generic project that can be called from other projects whenever we need to copy a file. All that the calling project has to do is provide old and new locations for each file that has to be copied. Typically reusable projects are used in iterations.
Following this example you can have a library of reusable projects for various file operations like deleting, moving or renaming files. Typical use cases for mass operations with files include:
Similarly to iterating EasyMorph projects, external applications can be iterated as well with the help of the "Iterate program" action. This action is similar to "Iterate" action, but instead of running another EasyMorph project it runs specified external application once for each row of a dataset. The command line in this case is specified using an expression. Therefore it can be calculated for each line of the dataset using fields, functions and parameters.
If the external application is not defined, the action executes the command line as a Windows shell command. It can be used, for instance, for mass copying/deleting/moving files without reusable projects.
Hint: To see what a calculated command line would look like you can pre-calculate command lines as a new column before iterating.
The "Run program" action allows capturing terminal screen output of an application or Windows shell commands. To capture output tick "Capture output" checkbox in the action properties. Both STDOUT and STDERR are captured. Typical use cases for output capturing include error handling and obtaining calculation results from extrnal applications without creating a file.