KB Article #180121

EL: Adding timestamp to the file name, preserving the original file extension

Problem

Add the current time stamp to the file name, preserving the original file's extension when doing a Server Initiated Pull.


For example:


The source file on the remote server test.txt to be pulled and stored on SecureTransport as test_20190930145433.txt


Resolution

The following Expression Language should be put in the Transfer Site, in the Post Transmission setting -> Receive file as field:


${basename(stenv.target)}_${date('yyyyddMMHHmmss')}${extension(stenv.target)}


The date() function accepts as parameter the format in which the time stamp should be printed out. The format follows the Java Simple Date Format notation as explained here.