# rename file after receiving

**URL:** <https://community.cdata.com/t/rename-file-after-receiving/361>\
**Category:** CData Sync\
**Tags:** question\
**Created:** [August 28, 2023, 4:01pm UTC](https://community.cdata.com/t/rename-file-after-receiving/361 "2023-08-28T16:01:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvbert1969](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@bvbert1969](https://community.cdata.com/u/bvbert1969)\
**Post date:** [August 28, 2023, 4:02pm UTC](https://community.cdata.com/t/rename-file-after-receiving/361/1 "2023-08-28T16:02:00Z")

</div>

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 →&nbsp;EUC2312\_20230828101211.xml  
EUC2313.xml →&nbsp;EUC2312\_20230828101313.xml

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

---

<div class="post-metadata">

**Author:** ![PukhrajChoudhary](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PukhrajChoudhary](https://community.cdata.com/u/PukhrajChoudhary)\
**Post date:** [August 29, 2023, 7:54am UTC](https://community.cdata.com/t/rename-file-after-receiving/361/2 "2023-08-29T07:54:51Z")

</div>

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

Original file name:&nbsp;990Response\_Input.xml

Expected file name:&nbsp;990Response\_Input\_2023082913210100.xml

---

<div class="post-metadata">

**Author:** ![bvbert1969](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@bvbert1969](https://community.cdata.com/u/bvbert1969)\
**Post date:** [August 29, 2023, 9:35am UTC](https://community.cdata.com/t/rename-file-after-receiving/361/3 "2023-08-29T09:35:59Z")

</div>

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%

---

<div class="post-metadata">

**Author:** ![RichardG](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/richardg/32/459_2.png) [@RichardG](https://community.cdata.com/u/RichardG)\
**Post date:** [August 31, 2023, 9:23am UTC](https://community.cdata.com/t/rename-file-after-receiving/361/4 "2023-08-31T09:23:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![PukhrajChoudhary](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PukhrajChoudhary](https://community.cdata.com/u/PukhrajChoudhary)\
**Post date:** [August 31, 2023, 11:42am UTC](https://community.cdata.com/t/rename-file-after-receiving/361/5 "2023-08-31T11:42:45Z")

</div>

\<!-- 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” /\>

---

<div class="post-metadata">

**Author:** ![RichardG](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/richardg/32/459_2.png) [@RichardG](https://community.cdata.com/u/RichardG)\
**Post date:** [August 31, 2023, 12:46pm UTC](https://community.cdata.com/t/rename-file-after-receiving/361/6 "2023-08-31T12:46:01Z")

</div>

Just to be sure, let’s say I want a file to be renamed from&nbsp;_ **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?

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/james_b/32/1688_2.png) [@James\_B](https://community.cdata.com/u/James_B)\
**Post date:** [September 1, 2023, 2:24pm UTC](https://community.cdata.com/t/rename-file-after-receiving/361/7 "2023-09-01T14:24:03Z")

</div>

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 &nbsp; - to prefix your AS2 file with a static string, you’d simply set the Local File Scheme to this:

```auto
Company-%Filename%

```

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

```auto
%FilenameNoExt%-%DateFormat:yyyyMMddHHmms%%Ext%

```
