Skip to main content
Solved

rename file after receiving

  • August 28, 2023
  • 6 replies
  • 444 views

Forum|alt.badge.img

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

Best answer by James B

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%

 

This topic has been closed for replies.

6 replies

Forum|alt.badge.img

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

 


Forum|alt.badge.img
  • Author
  • Apprentice
  • August 29, 2023

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%


RichardG
Forum|alt.badge.img
  • Collaborator
  • August 31, 2023

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?


Forum|alt.badge.img

<!-- 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" /> 


RichardG
Forum|alt.badge.img
  • Collaborator
  • August 31, 2023

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?

 

 

 

 


James B
Forum|alt.badge.img
  • Employee
  • Answer
  • September 1, 2023

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%