# check for new file in directory

**URL:** <https://forum.knime.com/t/check-for-new-file-in-directory/32328>\
**Category:** KNIME Analytics Platform\
**Created:** [April 18, 2021, 3:07pm UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328 "2021-04-18T15:07:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonG](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@RonG](https://forum.knime.com/u/RonG)\
**Post date:** [April 18, 2021, 3:07pm UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/1 "2021-04-18T15:07:56Z")

</div>

Is it possible to check if there is a file in a specific directory and if so run the workflow. And if there is a new file in the directory the workflow runs again.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [April 18, 2021, 3:12pm UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/2 "2021-04-18T15:12:03Z")

</div>

There was a debate about a similar task and I built a workflow to suggest how this could work. For more advanced scenarios you might want to check out the [KNIME server](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/53).

> [@Start a Workflow, e. g. a database query, after a certain time](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/36):
>
> @USCHUKN1ME I tried to build a system you might be able to expand and use. The idea is to have a workflow that would iterate a number of times (v\_number\_of\_intervals) with a set interval (of seconds) between (v\_seconds\_interval) them. The workflow looks for a trigger\_file.csv if this file has changed from the last time the loop has run a component would be executed. If the file has not changed nothing would happen. Admittedly not the most elegant way but you could build a small automatic execu…

---

<div class="post-metadata">

**Author:** ![RonG](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@RonG](https://forum.knime.com/u/RonG)\
**Post date:** [April 20, 2021, 5:44am UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/3 "2021-04-20T05:44:42Z")

</div>

Hi mlauber71,

thanks for this link. To be honest it isn’t completely clear for me how to do it.  
I will give it a try and will let you know later on if I succeeded

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [April 20, 2021, 5:47am UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/4 "2021-04-20T05:47:23Z")

</div>

Maybe other ideas in the thread can help. Like this component:

> [@Start a Workflow, e. g. a database query, after a certain time](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/41):
>
> You could absolutely combine the approaches, I would think. Thank you @kienerj for pointing to this feature. Another interesting function could be [this component](https://forum.knime.com/t/need-node-to-watch-directory-to-start-automated-process-please-help/18002/4) by @gab1one that would wait for a file to change. In order to bring this into a ‘looping system’ - some changes might be necessary. In my example I tried to do a small such system with generic KNIME nodes.

In the end such a thing could be a task for the KNIME server.

---

<div class="post-metadata">

**Author:** ![Brotfahrer](https://forum-cdn.knime.com/user_avatar/forum.knime.com/brotfahrer/32/24311_2.png) [@Brotfahrer](https://forum.knime.com/u/Brotfahrer)\
**Post date:** [April 20, 2021, 3:32pm UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/5 "2021-04-20T15:32:55Z")

</div>

Hello @RonG ,

maybe you are looking for such like this

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/0/3057947c465b8c242ca9dec2890633fec2a081ed.png)

I created a workflow where I list files on a network drive and compare this list with a table I write at the end of my workflow. After checking if files have to be renamed an copy to another network drive the “sub workflow” will be only executed when it receives a table with data.  
At the end of the workflow I concatenate the new file information with the old one and write this information to a table with the Table Writer Node.

![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/c/bc5e524fa092404bf6868b0606dfedc2c6ce89c2.png)

I hope this helps you to get an idea for your problem.

Greetings, Brotfahrer

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [April 20, 2021, 4:12pm UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/6 "2021-04-20T16:12:21Z")

</div>

Use the wait node and let the trigger be the new file

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [October 20, 2021, 4:12am UTC](https://forum.knime.com/t/check-for-new-file-in-directory/32328/7 "2021-10-20T04:12:53Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
