5

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.

0

2 Answers 2

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.

6
  • 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? Commented Oct 5, 2015 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
    Commented Oct 5, 2015 at 19:34
  • What's the path of the folder?
    – Firelord
    Commented Oct 5, 2015 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. Commented Oct 6, 2015 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
    Commented Jun 3, 2017 at 21:12
1

Use free and open source software to ensure better privacy. I found Easer especially good. However, it does seem to require root permissions for this specific task.

  1. Download the F-Droid store and then install Easer.

  2. Once you have the app, open "Settings" from the app-drawer and tick "Use root features". Then go to "Settings" > "Activated skills" and make sure that "Run commands" and "Time" are ticked.

  3. Now go to "Data" > "Event" and add a new "Time" event, specifying the time that you would like the files to be deleted.

  4. Go to "Data" > "Profile" and add a new "Run commands" profile. Add the following to the command: rm -rf <DIR-PATH>/*

  5. Go to "Data" > "Script" and add a script with the profile and event which were created above.

  6. Go to "Outline" and press "Start" from the menu.

Voila, and enjoy!

2
  • I followed abrac's instructions, but I'm confused about how I specify what folders I want cleared. Any help?
    – Jean
    Commented Jan 10, 2022 at 13:23
  • Hi Jean. Let's say that you want the Downloads folder cleared. The path to the Downloads folder is /sdcard/Downloads/. You would put that path where I specified <DIR-PATH> in step 4. Does it make sense now?
    – abrac
    Commented Jan 11, 2022 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .