I found myself in the position that I have „temporary“ files which I upload to my Nextcloud instance that I actually don’t want to stay forever (slowly eating up my storage). Reasons for this might be files I only need for a couple of days / weeks. Or large files I want to send others and I don’t need the files anymore in the cloud once the receiver downloaded them.

So what I did was creating a directory called /tmp which contained such files and I sporadically went in there and bulk-deleted everything I didn’t need anymore. This is a bit tedious and should be automated!

There is actually an open issue at the retention’s app GitHub repository, however it doesn’t look like there is any work done yet. So we need to help ourselves with a workaround.

With Nextcloud we can have files in a given directory be automatically deleted after a certain time! Let’s check this out!

How to auto-delete files in a folder with Nextcloud


We want files inside a certain Nextcloud-directory (let’s call it /tmp) to be automatically deleted after 14 days of their creation date.

  1. Install Automated Tagging and Retention app.
  2. Create a retention-parent tag and tag the /tmp directory with it.
  3. Create tags like auto-delete-two-weeks and use those for the retention settings (Admin>Workflow>File retention)
  4. Create an automation tagging rule which tags files with eg. auto-delete-two-weeks. As a condition choose that they must be tagged with retention-parent (files created inside the /tmp directory will have this retention-parent tag).
  5. Test it by uploading a file to /tmp and check whether auto-delete-two-weeks has been attached to it.
  6. Profit


Detailed Tutorial:

First we install the two apps which are needed for our workaround:

The apps can be installed by going to the apps view of your Nextcloud instance and search for them in the organization and tools categories. Click enable for both.

Next, we create the following labels via Admin>Workflow:

  • retention-parent
  • auto-delete-one-week
  • auto-delete-one-month
  • (and others if you want to manually add those labels to files which should be automatically deleted in the future)

We now insert the wished labels (auto-delete-one-[week,month]) to the file retention settings (also at the workflow tab) and set the corresponding retention times as seen in the screenshot below. The retention-parent tag must not to have any retention time!

So let’s get to the step where we make Nextcloud attaching the auto-delete-one-month tag automatically to files in a wished directory like /tmp.

We therefore use the Files automated tagging app and configure it as seen in the next screenshot. The condition is that the file is tagged with the retention-parent tag. Note that files which are uploaded to a directory with this label also have this tag!


The last step is to tag the /tmp directory with the retention-parent tag.

We can now test the setup by uploading a file into the /tmp directory. When opening the details-sidebar of the file we should see that the tag auto-delete-one-month has been added to the file’s list of tags. This makes the retention app removing the file in one month.



I hope this was helpful! If you have questions or hints, just put them into the comments section. Feel free to share this trick with your fellow Nextcloud-users! 🙂

 Use this for a public file drop

So another use-case I’m using this for is my public upload directory. I have a shortlink to a publicly shared folder in Nextcloud with the „file drop“ sharing settings. When files are uploaded I normally move them to other folders, download them etc. So I don’t need the uploaded files forever.

With the above trick I can auto-delete files in my public upload directory after some month.