Trading configuration > Fields for modifying application pickups and application deliveries > File renaming patterns

File renaming patterns

This chapter describes the use of file renaming patterns when you create or manage partner and application deliveries of the type:

For each of these delivery types, you can select the option to define a naming construction pattern for the new generated file names and for automatic duplicate file naming. To configure the resulting file naming, you must enter a naming pattern in the Pattern field.

The information in this chapter also applies to fields you complete for the:

The values you can enter in the Pattern field vary depending on the use case.

Delivery exchange and Message Handler rename patterns

You can enter any combination of the following elements it the Pattern field for Delivery exchange file naming and duplicate handling, and Message Handler file renaming actions:

Examples

The incoming file name (before any renaming takes place) is represented by the tags $filename$ and $extension$. For example, an incoming file named TestFile1.txt would have the name defined by the tags:

You could enter the following patterns in the Pattern field to obtain the following results.

Pattern Example result
New$filename$$extension$ NewTestFile1.txt
My$filename$_$sequence$$extension$ MyTestFile1_53.txt
$filename$_$sequence$$extension$ TestFile1_54.txt
%ReceiverRoutingId%_%metadata that is not found%_%SenderRoutingId%_$sequence$$extension$ ZZHERE__ZZP_101.txt

Delivery exchange duplicate file name patterns

In the Filename tab for FTP and File System exchanges you can set Duplicate file renaming by entering a renaming pattern in the Pattern field. The patterns that you can enter in this field are similar to the renaming patterns listed above, with the following differences:

You must include $filename$.

You must enter at least one of the following elements, in order to ensure that a unique name is generated for the duplicate:

How Activator handles file and duplicate file naming

The Activator trading engine sets the filename and extension values immediately before it parses the name value for any pattern-based naming modification. This means that file renaming is based on the current filename value, immediately before the renaming operation. When the filename value is changed during a renaming operation, the new file name is used for the next renaming operation that occurs in the message flow. So in the case where the file name is changed, it is no longer the original incoming filename value that is used in the next rename operation, but the actual current value.

Example:

  1. A pickup consumes the file My.txt.
  2. You have configured the Message Handler with the File Rename Rule Pattern $filename$File$extension$.
  3. Filename result = MyFile.txt
  4. A file system delivery is configured with the File Rename Pattern $filename$$extension$.backup .
  5. Filename result = MyFile.txt.backup
  6. Suppose Activator detects a filename duplicate - the file MyFile.txt.backup already exists at the delivery location. You have configured the file system delivery with a Duplicate Rename Pattern $filename$_$timestamp$$extension$.
  7. Filename result = MyFile.txt20130215113703512.backup

About dots (.) in extension tags

In renaming patterns, the existing metadata element ConsumptionFilenameExtension always includes the dot.

If the $extension$ tag did not have the dot, there would be many situations when you would have to enter a pattern such as $filename$.$extension$, which produce defective results when the incoming file name had no extension at all.

Examples:

Incoming file=FileWithoutExension with pattern $filename$.$extension$ is renamed FileWithoutExension.

Incoming file=FileWithoutExension with pattern $filename$.$extension$.backup is renamed FileWithoutExenstion..backup. (Note the duplicate dot in the result).

To prevent this error, the extension tag includes the full extension, if any, including the dot. Therefore $filename$$extension$ tags work in all cases, without problem.