Delete file older than x day, but for some users and some directory only

Hi, I want nextcloud delete files older than X days, but only for some users and only for some directory, how to achieve it?

my nextcloud have some users, use foldersync/android app to sync Whatsapp files to nextcloud,
(android/whatsapp <-> nextcloud/whatsapp folder, two way sync),
and they want delete files in this whatsapp folder older 180 days.

use shell script / cron,
find /nextcloud/data -type f ( -mtime +180 -o -ctime +180 ) -exec rm -f {} ;
then sudo -u _cloud php /var/www/nextcloud/occ files:scan --all

is it OK? what is the proper way to achieve it? any idea?

Any one?
Any idea?


Have the read some information about the files-retention app? You opened this thread under that category already :wink:
In my opinion a shell script doesn’t make sense here. Rather use auto-tagging and files retention. Both can be found for an admin user under “Settings” -> “Workflow”

There you can:

  1. create Collaborative Tags, for example “Auto-Delete” and “WhatsApp”
  2. create an entry for “Automated Tagging”, for example
    • name=WhatsApp-Auto-delete
    • tag=Auto-Delete
    • rule set:
      • File System Tag -- is tagged with -- WhatsApp
      • user group membership -- is -- yourSpecialGroup
  3. create entry for File Retention, for example:
    • select tag = “Auto-Delete”
    • 180 Days

Hi, I think I miss read the “File System Tag”,
I will try it later, thank you.:+1:

I think I miss understand “File System Tag” again :frowning:

Anyway, my problem is, I do not know,
how to tag the files, only in some folder (eg: “whatsapp” in nextcloud root)?

File System Tag can not do this, right?


Damn, I forgot to mention the step to add the tag “WhatsApp” to the file WhatsApp (in which your files are you want to delete after 180 days).
So open the details of that folder and add tag WhatsApp in the top of the details. You’ll find it.
Can’t create a screenshot right now.

Hi, do I need to install app to do this? (tag the folder)
I can not find, where can I tag the folder (both web and android).

Or is it possible do that on command/console? occ?

Well yes, you need the following apps enabled:

  • Files automated tagging
  • Collaborative tags
  • Retention

If these are enabled you should be able to tag folders here:

In case that tag symbol is totally missing, please check that:

  • nothing is blocking content from the web GUI (uOrigin and sometimes some antivirus tools are blocking content (buttons), so probably disable them testwise)
  • you cleared your browser cache
  • fully reload your web site in the browser by pressing CTRL + F5

My nextcloud is version: 14.0.4
and the apps is, Collaborative tags 1.4.0, Files automated tagging 1.4.0, Retention 1.3.1.

I still can not tag the file/folder manually, when I click the Tags on web interface,
It show nothing (yes, I already added public tag name “whatsapp”).
I do not know why, I just can not assign them :frowning:

Is it bug?

I have 14.0.4 too.
I see the same symptoms.

Unfortunately all my servers are on NC15 right now. I will check on my server anyway if I see further issues there as well.
Maybe somebody of you could investigate a little further on your servers.
Browser console output, maybe have a look at the browsers investigator if some elements are “hidden”.
Check if there are error messages in the Nextcloud log as well please.

Maybe related

“The backport to stable14 failed. Please do this backport manually.”


I just ran some tests. Tagging and Automatic Tagging perfectly work with NC15.
Retention on the other hand only work with a small limitation: you can create a new retention, but you can see your configured retentions in the web GUI afterwards and therefor cannot remove them via retention settings.
They can be likely removed by deleting the tag itself, but I haven’t tested that so far, because I was on prod server.