Solved

rename file after receiving

  • 28 August 2023
  • 6 replies
  • 188 views

Userlevel 1
Badge

Dear all, apologizes in advance for the probably silly question, but I am new at this and I could not find any example

a customer of mine is sending me a file always with the same filename, and I need to be able to save it and be sure that it will not be overwritten
for example adding a timestamp would be perfect (but preserving the extension)
EUC2313.xml → EUC2312_20230828101211.xml
EUC2313.xml → EUC2312_20230828101313.xml

how could I do this ? I can not use filepath or filename

icon

Best answer by James B 1 September 2023, 16:24

View original

6 replies

Userlevel 1
Badge

I am also looking for the same script to append the file name. I am getting API response and need to add  yyyyMMddHHmmssff in the file name while archiving into Azure blob.

 

Original file name: 990Response_Input.xml

Expected file name: 990Response_Input_2023082913210100.xml

 

Userlevel 1
Badge

I found a way, but actually depends on the connector used (I did not realize before, sorry)

I am using AS2 connector and there is an option to define a mask for saving, using wildcards

it is very easy

%FilenameNoExt%-%AS2MessageId%%EXT%

Userlevel 1
Badge

Is it also possible to add additional text to the filename, for example the name of a company, which isn't defined in one of the macro's?

Userlevel 1
Badge

<!-- Adding datetime to output Filename using script connector→


<arc:set attr="output.filepath" value="[filepath]" />
<arc:set attr="output.filename" value="[filename | replace('.xml',_[now('yyyyMMddHHmmssff')])].xml"/>
<arc:push item="output" /> 

Userlevel 1
Badge

Just to be sure, let's say I want a file to be renamed from 990Response_Input.xml to Company-990Response_Input.xml, but the "Company-” name is not the name of a Connector.

How can I add the text "Company-” in front of the current filename, as I can't use the replace formatter?

 

 

 

 

Userlevel 6
Badge

Hi Richard, Bvbert,

 

It seems to me that you are both using CData Arc, and if that is the case, every connector has a field in the Advanced tab called Local File Scheme - this field can be used to rename the output file from it’s original format into a new pattern, using macros to dynamically resolve the original filename or values such as a timestamp.

 

@RichardG  - to prefix your AS2 file with a static string, you’d simply set the Local File Scheme to this:

 

Company-%Filename%

 

@bvbert1969 - to append a timestamp regardless of the original filename, you can use a combination of macros:

%FilenameNoExt%-%DateFormat:yyyyMMddHHmms%%Ext%

 

Reply