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.
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:
%metadata name%
– You can use any metadata attribute associated with the FTP or File System delivery. You cannot use Custom attributes.$filename$
$extension$
$timestamp$
– Where timestamp
is a shortcut for SimpleDateFormat string ‘yyyyMMddHHmmssSSS’.$sequence$
– This is a monotonically increasing counter. A different counter is maintained for each delivery exchange. A Message Handler rule uses a single global counter.$any legal Java SimpleDateFormat string$
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:
$filename$
= TestFile1$extension$
= .txt (note that the dot is included)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 |
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:
sequence$
– This is the sequence number calculated from all delivery file names handled on all deliveries$timestamp$
$filesequence$
– This variable is only allowed in the duplicate file naming case (not the file naming case above). It is calculated from only the file names handled on the specific delivery where you set the pattern. It is recommended that you use $sequence$ instead of $filesequence$ because $filesequence$ consumes greater processing resources.$any legal Java SimpleDateFormat string$
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:
My.txt
.$filename$File$extension$
. MyFile.txt
$filename$$extension$.backup
. MyFile.txt.backup
MyFile.txt.backup
already exists at the delivery location. You have configured the file system delivery with a Duplicate Rename Pattern $filename$_$timestamp$$extension$
. MyFile.txt20130215113703512.backup
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.