Created on 10-09-2019 10:06 AM - last edited on 10-09-2019 09:52 PM by ask_bill_brooks
Hi Team,
I want to rename/modify the filename of the flowfile with the timestamp added to it. Let's say the original flowfile name is file1.txt, I want to change the name of file to be file1_<timestamp>.txt. I used updateAttribute processor to do it. The expression which I gave is
${filename:substringBeforeLast(‘.’)}_${now():format("yyyy-MM-dd HH:mm:ss.SSS’Z’”)}.${filename:substringAfter('.')}
This Giving me error. I'm bad at Expression language. could anyone help me in this?
Thanks.
Created 10-10-2019 10:15 AM
Hello @girish6
Your first EL statement would work as well once you correct the single quote marks around the Z.
Many outside text editors end up messing up the single quotes, so the NiFi EL ends up being incorrect when you copy/paste.
NiFi's EL editor built in to the processor property text blocks can help identify when the EL format is wrong.
In above you can see your NiFi EL statement as copied and pasted on line 3. You'll notice the color coding indicates an issue with the function's input parameters.
Line 1 has the properly formatted version of that same NiFi EL statement.
Be careful when using copy paste from some external editors.
Thank you,
Matt
Created 10-09-2019 10:25 AM
${filename:substringBeforeLast(‘.’)}_${now():format("yyyy-MM-dd-HH-mm-ss")}.${filename:substringAfter('.')}
This expression worked fine. Thanks
Created 10-10-2019 10:15 AM
Hello @girish6
Your first EL statement would work as well once you correct the single quote marks around the Z.
Many outside text editors end up messing up the single quotes, so the NiFi EL ends up being incorrect when you copy/paste.
NiFi's EL editor built in to the processor property text blocks can help identify when the EL format is wrong.
In above you can see your NiFi EL statement as copied and pasted on line 3. You'll notice the color coding indicates an issue with the function's input parameters.
Line 1 has the properly formatted version of that same NiFi EL statement.
Be careful when using copy paste from some external editors.
Thank you,
Matt