# Counting Files in Folders

**URL:** https://discuss.elastic.co/t/counting-files-in-folders/281023
**Category:** Kibana
**Created:** [August 11, 2021, 9:26am UTC](https://discuss.elastic.co/t/counting-files-in-folders/281023 "2021-08-11T09:26:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tractor\_boy](https://avatars.discourse-cdn.com/v4/letter/t/278dde/32.png) [@tractor\_boy](https://discuss.elastic.co/u/tractor_boy)
#### Post date: [August 11, 2021, 9:26am UTC](https://discuss.elastic.co/t/counting-files-in-folders/281023/1 "2021-08-11T09:26:05Z")

</div>

Hi,  
Is there a way to capture the number of files that exist in a folder where the file has not been modified for a period of time?

I have a requirement to capture this information, and then build alarms of the back of this data.

I have googled but yet to find a solution, so any links to the solution would be appreciated.

The solution must not consume those files into elastic.

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [August 11, 2021, 10:36am UTC](https://discuss.elastic.co/t/counting-files-in-folders/281023/2 "2021-08-11T10:36:27Z")

</div>

If you can get the correct command and parse it you can do it with [logstash exec](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-exec.html) input plugin. Now you just need to find which command works for your OS. For instance on Linux you can use `ls | wc -l` to get the file count of a folder.

I don't know of a way to do it without Logtash.

---

<div class="post-metadata">

### Author: ![tractor\_boy](https://avatars.discourse-cdn.com/v4/letter/t/278dde/32.png) [@tractor\_boy](https://discuss.elastic.co/u/tractor_boy)
#### Post date: [August 11, 2021, 10:51am UTC](https://discuss.elastic.co/t/counting-files-in-folders/281023/3 "2021-08-11T10:51:38Z")

</div>

Apologies as very new to the whole ELK stack.

So you have to create a process that writes the answer to a file, and then consume that file into elastic, for that to the read the contents and process accordingly?  
If that is correct then when the file is overwritten with the new value then does elastic know that the value has changed, or do you have to create a new file each time?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 8, 2021, 10:52am UTC](https://discuss.elastic.co/t/counting-files-in-folders/281023/4 "2021-09-08T10:52:14Z")

</div>

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