How to clear a Folder (e.g. Downloads) automatically on a regular/scheduled basis? There is a folder on an Android phone that continually fills with junk.

Instead of clearing that folder manually on a regular basis, how can I setup up a way to have that folder be automatically cleared (e.g. all its contents deleted) on a regular basis (e.g. daily) to free up space?

Or is there a (free) App that does that?

It's a very simple task, but I can't seem to find a way or an App that allows one to select a specific folder (e.g. other than cache) and have it automatically clear that specific folder on a regular basis set by the user.
MacroDroid (free up to five macros) can do the job. 

The macro would be:


Trigger: Day/Time Trigger &rarr; select all the days and choose the time for trigger activation
Action: File Operation &rarr; Delete &rarr; select the folder that needs to be cleared &rarr; All Files

Edit: { There is a catch here. Unless the device is rooted, only the files at the top-level would be deleted i.e. the deletion wouldn't be recursive so any sub-directory would remain untouched.

The only option I found to nuke recursively is to delete the top-level folder itself. So instead of choosing All Files select Folder. }
Constraint: none


Done!



I prefer to use Tasker (paid; 7 day free trial) though.


Profile: Time 


From: choose the time for trigger
Repeat: 24 Hours
To: uncheck it 

Task: File


Delete Directory: choose or enter the directory's path 
Select Recurse


Alternatively, the action can be Code &rarr; Run Shell &rarr;  Command: rm -rf &lt;DIR_PATH&gt;/*

Replace &lt;DIR_PATH&gt; with the path of the directory, such as for DCIM folder under sdcard the whole command would be rm -rf /sdcard/DCIM/*


That should do the cleaning for every 24 hours.