Grinder’s Macro language
In order to make workflows easier to write and more flexible, Grinder provides a library of macros that are used to substitute values inside workflow actions. When grinder is making the substitutions it will search for values in the following order:
- Symbols
- File Properties
- Directory Properties
- Service Properties
- Environment variables
The format for a macro is ${macro}. For example ${FULLPATH}. Grinder will search for a macro named FULLPATH and substitute the value for ${FULLPATH}.
The following are the built in symbols:
| Macro | Description |
| GUID | Expands to a GUID |
| EXT | The extension for the file being processed |
| FILENAME | The filename without the full path for the file being processed. |
| WORKITEMFILENAME | The name of the file being worked on. |
| FILENAMENOEXT | The filename of the file being processed without the full path or the extension. |
| DIRECTORY | The path for the current file being processed. |
| FULLPATH | The full path to the file for the current file being processed. |
| RND | Generate a random number between 0 and 1000 |
| ARCHIVEPATH | Path to the archive directory |
| DATE | Expands to the current date based on the supplied format string. For example – DATE(yyyyMMdd) will generate 20071008. Date format macros: | yyyy | year, It will always be formatted with 4 digits, which will cause an issue for the year 9999. | | MM | month. It will always be formatted with two digits | | dd | day. It will always be formatted with two digits | | HH | hour in twenty-four format. It will always be formatted with two digits | | mm | minutes. It will always be formatted with two digits | | ss | seconds. It will always be formatted with two digits. | The format string is the standard data format string used by .NET’s DateTime object. Any valid DateTime format string will work here. |
As an example:
When setting up the File Copy action the source file would use ${FULLPATH} in order to get the path to the file being worked on. To copy the file to a client directory and add a date time stamp you would use the following: d:\clients\${CLIENTID}\${FILENAME}_${DATE(yyyyMMdd)}.${EXT}.
Using Grinder's configuration editor will allow you to associate macros like CLIENTID to a directory. This provides the flexibility to move files around based on the file type, the directory is came in or other variables.