# How to detect newly added files ?

**URL:** https://forum.syncthing.net/t/how-to-detect-newly-added-files/14982
**Category:** Support
**Created:** [May 10, 2020, 9:29pm UTC](https://forum.syncthing.net/t/how-to-detect-newly-added-files/14982 "2020-05-10T21:29:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fulstop](https://forum.syncthing.net/user_avatar/forum.syncthing.net/fulstop/32/5237_2.png) [@fulstop](https://forum.syncthing.net/u/fulstop)
#### Post date: [May 10, 2020, 9:29pm UTC](https://forum.syncthing.net/t/how-to-detect-newly-added-files/14982/1 "2020-05-10T21:29:37Z")

</div>

This issue : [5541](https://github.com/syncthing/syncthing/issues/5541) has been closed by [this commit](https://github.com/syncthing/syncthing/commit/744ef0d8ac82fdc7315ed8330545247157acf602)

From now on, what is the best reliable way, polling the /events REST API endpoints to understand/infer that some file or folder has been added “for the first time” to a folder ?

As I understand there will be no more distinction between “first addition” and “modified since first addition”. I know that there were bugs in the past (one deleted filename added again on the same path was not considered as added), but in my use case I was listening to LocalChangeDetected and RemoteChangeDetected `added` actions to trigger notifications, which worked 99.9% of the time… and is a big part of my sync workflow…

As an example, imagine a dropbox-like subfolder where people drop content and other people get notifications about those additions.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [May 11, 2020, 5:44am UTC](https://forum.syncthing.net/t/how-to-detect-newly-added-files/14982/2 "2020-05-11T05:44:28Z")

</div>

I think you need to keep the state yourself. When your thing starts up, look what files are already present. Notifications for files not present mean “added”, and then you remember those names as well. On delete, forget them. This also works around the issue with previously deleted files.

---

<div class="post-metadata">

### Author: ![fulstop](https://forum.syncthing.net/user_avatar/forum.syncthing.net/fulstop/32/5237_2.png) [@fulstop](https://forum.syncthing.net/u/fulstop)
#### Post date: [May 21, 2020, 11:26am UTC](https://forum.syncthing.net/t/how-to-detect-newly-added-files/14982/3 "2020-05-21T11:26:55Z")

</div>

Thanks for your feedback, I will indeed use an external script to preserve this kind of state. One more question, in the [release notes for the rc of 1.6](https://github.com/syncthing/syncthing/releases/tag/v1.6.0-rc.5) you wrote:

> The `LocalChangeDetected` event no longer has the `action` set to `added` for new files, instead showing `modified` for all local file changes.

Is the omission of the `RemoteChangeDetected` event name intentional or did I not understand that the `added` action is only removed for `LocalChangeDetected` ?

As I understand the `added` is definitely removed for Remote and Local change file change notification events.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [June 20, 2020, 11:26am UTC](https://forum.syncthing.net/t/how-to-detect-newly-added-files/14982/4 "2020-06-20T11:26:57Z")

</div>

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