# Dynamic paths on File Connector

**URL:** <https://community.cdata.com/t/dynamic-paths-on-file-connector/228>\
**Category:** CData Arc\
**Tags:** question, cdata-arc, file\
**Created:** [June 30, 2023, 7:58am UTC](https://community.cdata.com/t/dynamic-paths-on-file-connector/228 "2023-06-30T07:58:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [June 30, 2023, 7:58am UTC](https://community.cdata.com/t/dynamic-paths-on-file-connector/228/1 "2023-06-30T07:58:32Z")

</div>

I need to pick up from a different path each day, so I need to have paths like

//SERVER/PathToRoot/_ddmmyy_

_ddmmyy_&nbsp;should be today’s date

I see I can use **%Header:xxxx%** but I think that will only work for sending out file, not collecting files.

Is there a way to set a Header when collecting files?

Are there any examples using a script and&nbsp; **fileListDir ?**

---

<div class="post-metadata">

**Author:** ![Arturo\_S](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@Arturo\_S](https://community.cdata.com/u/Arturo_S)\
**Post date:** [July 13, 2023, 3:19pm UTC](https://community.cdata.com/t/dynamic-paths-on-file-connector/228/2 "2023-07-13T15:19:03Z")

</div>

Hi @russell-jerseypost ,

If you are looking to pickup file from subfolders named specifically after the current date, you should be able to use the **DateFormat** macro in the directory Path that your File Connector is going to be interacting with. For your example it may be something like:

```auto
//SERVER/PathToRoot/%DateFormat:ddMMyy%

```

 ![a335abe7-c151-4f40-8c07-72de57d61cee.png](https://us1.discourse-cdn.com/cdata/original/1X/1c56163a4ca8bd83162c6cf8dcc03ccc0dc6386d.png)

This would pick up files from my 130723 subfolder as of the writing of this reply and it would start looking for files in the 140723 subfolder the following day.

 ![a1702ae1-fe81-4a95-982f-447d42f8e957.png](https://us1.discourse-cdn.com/cdata/original/1X/3eb1d4ff4e81756cd8b17aa6826788e200ba1481.png)

Regarding a sample script for **fileListDir** operation I have drafted up a simple script that will read through the files in a directory, count them, and output them into the Arc script connector, hopefully this helps:

```auto
<!--Set the path to read from and initialize counter--><arc:set attr="dir.path" value="C:\YourPath" /><arc:set attr="total.counter" value="0"/><!--Call operation, increment counter for each file in path, push each file to script connector output--><arc:call op="fileListDir" item="dir"> <arc:set attr="total.counter" value="[total.counter | add]" /> <arc:set attr="temp.filename" value="[dir.file:name]"/> <arc:set attr="temp.filepath" value="[dir.file:fullname]"/> <arc:push item="temp" /></arc:call><!--Output total count of files in the directory as an empty file--><arc:set attr="total.filename" value="There were [total.counter] files"/><arc:push item="total"/>

```
