# \[ANNOUNCE\]node-red-cleanup-filesystem - request for testing

**URL:** <https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135>\
**Category:** Share Your Nodes\
**Created:** [21 May 2024 06:01 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135 "2024-05-21T06:01:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [21 May 2024 06:01 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/1 "2024-05-21T06:01:32Z")

</div>

Hi folks,

I had installed a Reolink video doorbell a few weeks ago, and I was a bit tired of cleaning up the files and folders with recorded video footage.

Of course I could have created a cron job to do this, but where is the fun that way... I want to show everything that is going on on my machine visually in Node-RED.

So I quickly developed [@bartbutenaers/node-red-cleanup-filesystem](https://github.com/bartbutenaers/node-red-cleanup-filesystem/):

 ![WhatsApp Image 2024-05-20 at 10.21.33](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/8788d541075b948d20044fcd4c31ded28faeac67.jpeg)

Did some testing and looks to work fine. But unfortunately I have still very limited spare time, and I don't want people to loose important documents because me having some bug in my node...

Therefore I would really appreciate if somebody could do some more testing, also for edge cases like when properties are not filled in and so on. The safest way to do such tests is with _ **dry-run** _ option active.

This node is currently not yet available on npm, so it need to be installed within the .node-red folder:

```auto
npm install bartbutenaers/node-red-cleanup-filesystem

```

Thanks!!!  
Bart

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 May 2024 11:23 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/2 "2024-05-21T11:23:15Z")

</div>

I built a file structure on a RPI I have and added folders and files and this is what the file structure is:  
 ![Screenshot 2024-05-21 at 6.13.35 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/853562ead23dd5a58a6244c4c97feafedd759dae.png)

So I have folders within folders and some of them have files and some are empty.

(1) When I run with this setup:  
 ![Screenshot 2024-05-21 at 6.34.06 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/279d5eb7e498bf328f0716fba6b31cf7d1217692.png)

It successfully shows all the files and nested files:

 ![Screenshot 2024-05-21 at 6.36.39 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57e502efb7c942318de9297733e25dc31ce99333.png)

but no `folders` are listed

(2) when run with this setup:  
 ![Screenshot 2024-05-21 at 6.44.39 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af02fc8ef061bb8d4963faeb641f0504f588b1cd.png)  
It reports all the files in the `bart_test` folder and all the files in the `bart_test/deleteMe` folder

 ![Screenshot 2024-05-21 at 6.36.39 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57e502efb7c942318de9297733e25dc31ce99333.png)  
I expected it to only show the files in the `bart_test/deleteMe` folder

(3) Documentation issues (a picture is suppose to be worth a thousand words)

 ![Screenshot 2024-05-21 at 6.59.36 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f1d1f0cfd99187257c4f20102a74e2822e9e8f4.jpeg)  
I believe the documentation should use `Filename` instead of `fileNamdPatterns` and the same for the other options.

(4) Passing in a parameter:  
I tried passing a parameters to the node using `msg.baseFolder` to send the folder name. That generated an error:

`Specify 'payload.baseFolder' (different from root folder) when not specified in the config screen.`

using msg.payload.Basefolder seems confusing and is not in the documentation. I'd suggest using msg.Basefolder of msg.cleanup.Basefolder

That's all for now 😀

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [21 May 2024 12:07 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/3 "2024-05-21T12:07:41Z")

</div>

@zenofmud  
This is most kind of you...  
Thanks a lot!! Really appreciated.  
Will get to it this evening.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [23 May 2024 21:59 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/4 "2024-05-23T21:59:21Z")

</div>

> [@zenofmud](#):
>
> I built a file structure on a RPI I have and added folders and files and this is what the file structure is:

Hi @zenofmud,  
thanks a lot for testing!  
You guys in the US have other food habbits compared to me, while having a look at the file names of your pictures in your folders 😋

> [@zenofmud](#):
>
> but no `folders` are listed

That should be ok. If you have unselected the _"Remove empty subfolders"_ option, then no folders will be removed. So no folder names in the report, because the report only shows the folders and files that will be removed. I have added that in bit more in detail in the docs now...

> [@zenofmud](#):
>
> I expected it to only show the files in the `bart_test/deleteMe` folder

Yes you are absolutely right. The folder name filtering was very confusing and incorrect. I hope it is fixed now in the code. I have also added an example in the readme page.

> [@zenofmud](#):
>
> Documentation issues (a picture is suppose to be worth a thousand words)

Yes indeed a picture with thousands pink lines is more worth than a thousand words 🤣  
That should now also be fixed in the code.

> [@zenofmud](#):
>
> I tried passing a parameters to the node using `msg.baseFolder` to send the folder name. That generated an error:

Yes that is normal because you should inject `msg.payload.baseFolder` instead of `msg.baseFolder`. Is that not clear in the docs?

Hopefully you can find somewhere some extra time to test it again. Thanks!!

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 May 2024 04:17 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/5 "2024-05-24T04:17:10Z")

</div>

Very nice @BartButenaers

Now I can replace my old Python scripts that basically does the same but has no gui, so very nice idea and thanks a lot!!

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 May 2024 04:19 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/6 "2024-05-24T04:19:02Z")

</div>

> [@BartButenaers](#):
>
> ou guys in the US have other food habbits compared to me

I expect that list is just the starter??

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [24 May 2024 04:20 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/7 "2024-05-24T04:20:38Z")

</div>

Haha indeed 🤣  
It is a shame that I have abused Paul's screenshot to start joking, because he has already been so kind to assist me 🥰

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 May 2024 04:44 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/8 "2024-05-24T04:44:55Z")

</div>

Just a thought, will this plugin be able to delete files & folders that are not owned by the current user? Why asking is because in my Python scripts I use sudo for those

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [24 May 2024 04:49 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/9 "2024-05-24T04:49:13Z")

</div>

I assume it can only remove files/folders to which the Node-RED user has access. And otherwise give the Node-RED user access to those resources.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 May 2024 04:49 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/10 "2024-05-24T04:49:47Z")

</div>

OK, fine I think

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 May 2024 04:59 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/11 "2024-05-24T04:59:18Z")

</div>

I also automatically schedule clean up of video captures from my cameras, they do consume a lot of space, but after 21 days so you have enough time "to act". Here is a fresh example from a week ago, unexpected visitor seemed interested in our cars

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9af0e38fae6d46e0192247368a3e3a7c34cc3c54.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0ffd8714d0dbee6f5e7a1aafa773ae17a6cf2d39.jpeg)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [24 May 2024 07:20 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/12 "2024-05-24T07:20:22Z")

</div>

> [@krambriw](#):
>
> unexpected visitor seemed interested in our cars

😮

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 May 2024 08:26 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/13 "2024-05-24T08:26:27Z")

</div>

What is that gadget he is wearing round his neck ?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [24 May 2024 10:02 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/14 "2024-05-24T10:02:52Z")

</div>

I have a couple more changes you need to make.

1. in the HELP for the node I'd suggest for `Filename` you use the full description from the GitHub description:  
`Files with a name matching this regex pattern will be removed. Use `.*` for all files. Multiple regex patterns can be entered `;` separated, for example `.*mp4;.*jpg` to remove only files with extension "mp4" or "jpg". The value from the config screen can be overwritten via `payload.fileNamePatterns` in the input message.`

(side note: using `payload.fileNamePatterns` will not work because the code looks for `payload.fileNamePattern` note the missing 's'

1. For Foldername I would use:  
`Folders with a (full path folder) name matching this regex pattern will be removed. Use .* for all folders. Multiple regex patterns can be entered following the example shown in Filename. The value from the config screen can be overwritten via payload.folderNamePatterns in the input message.`

You will need to change `payload.folderNamePatterns` in the code or documentation so they match.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 May 2024 10:35 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/15 "2024-05-24T10:35:13Z")

</div>

> [@zenofmud](#):
>
> regex patterns

File patterns are better suited to glob patterns.

With glob, you can do things more usual like `*.jpg`

> [@zenofmud](#):
>
> Multiple regex patterns

If the node is supporting multiple matches, it makes more sense to use a typedList

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [24 May 2024 11:01 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/16 "2024-05-24T11:01:25Z")

</div>

> [@dceejay](#):
>
> What is that gadget he is wearing round his neck ?

Can't really tell from the pic. Could just be a bag on a neck strap.

> [@Steve-Mcl](#):
>
> File patterns are better suited to glob patterns.
> 
> With glob, you can do things more usual like `*.jpg`

I agree with that. I use the `fast-glob` module to get good support. It also includes regex matches so you don't need lots of code to support both. There are examples in the `uib-file-list` node in uibuilder.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 May 2024 13:09 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/17 "2024-05-24T13:09:12Z")

</div>

> [@dceejay](#):
>
> What is that gadget he is wearing round his neck ?

I assume some useful tools. Nothing stolen or damaged this time, just the uncomfortable feeling remains (two visits with two days in between)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [24 May 2024 14:42 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/18 "2024-05-24T14:42:00Z")

</div>

@krambriw Are any of your cars 'keyless entry'? - just thinking about what is around his neck .. (no need to answer here!)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [24 May 2024 16:02 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/19 "2024-05-24T16:02:32Z")

</div>

We keep all our car keys in tin cans with lids (old mustard powder tins I think). Greatly reduces the ability to pick up any signals.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 May 2024 17:58 UTC](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135/20 "2024-05-24T17:58:56Z")

</div>

yeah - that is what I was thinking.

[Next page](https://discourse.nodered.org/t/announce-node-red-cleanup-filesystem-request-for-testing/88135.md?page=2)
