4

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.

5

MacroDroid (free up to five macros) can do the job.

The macro would be:

  • Trigger: Day/Time Trigger → select all the days and choose the time for trigger activation
  • Action: File Operation → Delete → select the folder that needs to be cleared → 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 → Run Shell → Command: rm -rf <DIR_PATH>/*

    Replace <DIR_PATH> 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.

  • Actually, MacroDroid did not work, unfortunately. I just checked the folder and the contents are still there. I had set it up as per above, it showed the macro was "activated" 4 hours ago, but the folders and files from yesterday are still in the folder that was set for deletion. Any ideas? – ProgrammerGirl Oct 5 '15 at 19:31
  • In the MacroDroid, under Macros you would see your macro. Attempt to execute it manually (long-press -> Test Actions) and see whether it works or not. Just asking, is the MacroDroid activated and has its icon showing in the status bar? – Firelord Oct 5 '15 at 19:34
  • What's the path of the folder? – Firelord Oct 5 '15 at 19:35
  • 1
    The problem is that i need the original folder to remain and only for its contents to be deleted. I was able to find a crude workaround by doing what you described in your previous comment, and then setting up a 2nd macro that runs 1 minute after and recreates the folder again. – ProgrammerGirl Oct 6 '15 at 20:05
  • 1
    My phone is rooted and the MacroDroid macro does not delete recursively unless I choose Folder. Also note that this option only exists for "File Operation", not for the new "File Operation V2". – CrouZ Jun 3 '17 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.