The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Auto-delete junk files in temp folders

To auto-delete junk files in temp folders, you can set up a routine using built-in tools or scripts on your system. Here’s a method for both Windows and macOS:

For Windows

  1. Using Disk Cleanup Tool:

    • Open the Start menu, type “Disk Cleanup”, and press Enter.

    • Select the drive you want to clean (usually C: drive).

    • In the Disk Cleanup window, check Temporary files, System error memory dump files, and other categories of unwanted files.

    • Click OK and then Delete Files.

  2. Automate Using Task Scheduler:
    You can create a scheduled task that runs a script to delete temp files automatically.

    • Open Task Scheduler (search it in the Start menu).

    • Click Create Task.

    • In the Actions tab, choose Start a program, then browse and select a batch script (we’ll write that next).

    • Under Triggers, set how often you want the task to run (e.g., daily, weekly).

    • Save the task.

    Here’s a simple batch script to delete files in temp folders:

    batch
    @echo off del /f /q %TEMP%* del /f /q C:WindowsTemp* rd /s /q %TEMP% rd /s /q C:WindowsTemp
    • Save this as cleanup.bat and point the Task Scheduler to run this script.

  3. Using CCleaner (Third-party Tool):

    • Install CCleaner and configure it to clean temp files automatically on startup or at scheduled intervals.


For macOS

  1. Use Terminal Commands:

    • Open Terminal and run the following command to clean up temporary files:

    bash
    sudo rm -rf /private/var/folders/* sudo rm -rf /Library/Caches/* sudo rm -rf ~/Library/Caches/* sudo rm -rf /tmp/*

    These commands remove temp files, cache files, and other junk.

  2. Automate Using Cron Jobs:
    You can set up a cron job to delete junk files on a regular basis.

    • Open Terminal and type:

    bash
    crontab -e
    • Add the following line to delete junk files daily:

    bash
    0 0 * * * /usr/bin/sudo rm -rf /private/var/folders/* && /usr/bin/sudo rm -rf /Library/Caches/* && /usr/bin/sudo rm -rf ~/Library/Caches/* && /usr/bin/sudo rm -rf /tmp/*

    This will clean the junk files every day at midnight.

  3. Third-party Apps (e.g., CleanMyMac):
    Apps like CleanMyMac allow you to automate cleanup tasks, including junk files, cache, and temporary files.


Would you prefer any specific method, or need more details for a certain platform?

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About