/clean_cache_debian_android

Remove cache and unwanted files from your Debian Distributions and even Android OS

Primary LanguageShell

Have you ever had your smartphone full of trash files that you want to get rid of? Are cleaning apps unreliable to certain trash files? If only there was a way to customize the files and folders that you want to delete... Oh wait, here's the solution!

These bash scripts allows users to delete their unwanted files (it can be anything) from their android device with one tap. Simply select the functions and the arguments that you want to use and run the script. Easy to use and effective when cleaning!


In order for this to work on Android, you need:

  1. Download and install Terminal Emulator for Android.
  2. Put the folder with the scripts on a directory of your choice.
  3. ONLY MODIFY THE CLEAN_CACHE_USER FILE with the available functions. Also beware that not all text editors for Windows work for this kind of script (It's because of the "Enter" key)!
  4. Put "bash PATH_TO_LOCATION/clean_cache_debian_android/CLEAN_CACHE_USER.sh" as the initial command in the preferences to run the file everytime you open the Terminal.
  5. Enjoy!

In order for this to work on a Debian Distribution, you need:

  1. Put the folder with the scripts on a directory of your choice.
  2. ONLY MODIFY THE CLEAN_CACHE_USER FILE with the available functions. Also beware that not all text editors for Windows work for this kind of script (It's because of the "Enter" key)!
  3. Execute "bash PATH_TO_LOCATION/clean_cache_debian_android/CLEAN_CACHE_USER.sh" on the terminal.
  4. Enjoy!

Functions:

  • remove_folder: delete folders.

    • all arguments: full path of the folders.
  • remove_file: delete files.

    • all arguments: full path of the files.
  • remove_type: delete files with the same extension from a certain folder.

    • 1st argument → directory where the folders are (full path).
    • 2nd argument → how many layers should the function go. Choose:
      • = 1 → only the folder itself.
      • > 1 → the main folder and subfolders, until they reach the maximum layer given.
      • = 0 → nothing happens.
      • anything else → the main folders and all subfolders.
    • 3rd to last arguments → extension type.
  • remove_folder_in_folders: remove certain folders within a directory.

    • 1st argument → directory where the folders are (full path).
    • 2nd argument → how many layers should the function go. Choose:
      • = 1 → only the folder itself.
      • > 1 → the main folder and subfolders, until they reach the maximum layer given.
      • = 0 → nothing happens.
      • anything else → the main folders and all subfolders.
    • 3rd to last arguments → folders to delete (name of the folder).
  • remove_file_in_folders: remove certain files within a directory.

    • 1st argument → directory where the files are (full path).
    • 2nd argument → how many layers should the function go. Choose:
      • = 1 → only the folder itself.
      • > 1 → the main folder and subfolders, until they reach the maximum layer given.
      • = 0 → nothing happens.
      • anything else → the main folders and all subfolders.
    • 3rd to last arguments → files to delete (name of the folder).
  • remove_empty_files_folders: delete empty files and folders in the main folders and in all subfolders.

    • 1st argument → main folder (full path).
    • 2nd argument → how many layers should the function go. Choose:
      • = 1 → only the folder itself.
      • > 1 → the main folder and subfolders, until they reach the maximum layer given.
      • = 0 → nothing happens.
      • anything else → the main folders and all subfolders.
    • 3rd to last arguments (optional) → folders and files to skip, if any (full path).

WARNING: THESE BASH SCRIPTS CAN DELETE IMPORTANT FILES IF YOU DON'T KNOW HOW TO USE! I WILL NOT TAKE RESPONSIBILITY IF IMPORTANT DATA ON YOUR DEVICE IS LOST! USE IT AT YOUR OWN RISK!


Future implementations:

Priority Description
Low Adding counters for the number of files, folders and the total size of everything that was deleted (in a far future).

Versions:

Version number Description
3.3
  • Removed 2 functions (remove_folder_within_folder and remove_file_within_folder) because they were just the two recursive functions (remove_folder_within_subfolder and remove_file_within_subfolder) on layer 1.
  • Renamed three functions:
    • remove_folder_within_subfolder to remove_folder_in_folders
    • remove_file_within_subfolder to remove_file_in_folders
    • remove_folder_within_folder to remove_type.
  • Warning messages were also improved.
3.2.1 Rewrite of the displayed error messages, because the caller function doesn't work on shell. So, instead of showing the line, now it shows the name of the function.
3.2 Rewrite of the version 3.1.3, to make all functions display error messages when arguments are missing.
3.1.3 Error message is displayed when the second argument of the last three functions is not an integer and shows the line where the function is called.
3.1.2 Added another condition to all functions that allow searching in layers to accept only integers on their second argument (remove_folder_within_subfolder, remove_file_within_subfolder and remove_empty_files_folders).
3.1.1 Added a condition to all functions (except remove_file and remove_folder) to skip them if the main folder doesn't exist.
3.1 Restored two functions where a folders and files can be directly deleted instead of searching for them (remove_file and remove_folder).
3.0
  • Complete overhaul on the system functions. Many bugs led to the rewrite of all them. All of them were fixed, some of them were renamed and others were created.
  • It was also added compatibility between Android and Ubuntu (they both use Shell).
  • Performance is lower than the other versions, but reliability was increased.
2.3.2 Fixed a bug on the last function, where at folders were not skipped.
2.3.1 Fixed bug in functions where not all arguments were parsed.
2.3 Altered the first 3 function in order to parse multiple arguments.
2.2.1 Fixed bug on remove_empty_files_folders function where it basically skipped the first argument as well.
2.2 Added the option to skip multiple files and folders in the function remove_empty_files_folders.
2.1 Created a README file.
2.0 Separating functions and user preferences into two separate files.
1.1 Resolving problems with permissions.
1.0 Cleaning some junk code and making it "look great".
0.6 Added a condition in the remove_empty_files_folders function to skip certain folders. Its not fully implemented yet.
0.5 remove_empty_files_folders can now delete empty files and folders from subdirectories.
0.4 function remove_empty_files_folders created, but only working in the main folder, not the subfolders.
0.3 remove_type was added.
0.2 implemented function remove_folder.
0.1.1 echo was added to the below function.
0.1 created remove function.