Windows
View all Worklets
WindowsWindows

Folder Clean Up

Automatically delete targeted files and folders to free up disk space on Windows endpoints

Worklet Details

What the folder cleanup Worklet does

This Automox Worklet™ removes specified files and folders from Windows endpoints to reclaim disk space and reduce system overhead. You configure the Worklet with target folders and exclusion rules before deployment. The Worklet evaluates each endpoint, identifies the configured directories, and removes files per your settings.

The Worklet supports both system-wide cleanup (like Windows Temp folders) and user-specific cleanup (such as AppData temporary directories). It can delete folder contents while preserving the directory structure, or remove entire folders if needed. You can also configure the Worklet to skip specific file types during deletion.

After files are removed, the Worklet can optionally delete any empty subdirectories that remain, further optimizing your endpoint storage.

Why automate folder cleanup on your endpoints

Accumulation of temporary files, cache data, logs, and unused content gradually consumes disk space and degrades endpoint performance. Manual cleanup across dozens or hundreds of endpoints is time-consuming and inconsistent. Automating this task keeps every endpoint optimized without requiring IT staff to touch each machine individually.

Cleaning up unnecessary files also reduces the data footprint for backup and disaster recovery operations, which can lower storage costs. Endpoints with cleaner file systems boot faster, launch applications more quickly, and provide better user experience.

The Worklet's flexibility allows you to define exactly what should be deleted, preventing accidental removal of important files or system components.

How folder cleanup remediation works

  1. Evaluation phase: The Worklet checks whether each configured target folder exists and contains files to delete based on your exclusion rules. It inventories user profiles on the endpoint to locate user-specific folders across all logged-in users.

  2. Remediation phase: The Worklet removes files from each folder according to your configuration. If force delete is enabled, it removes the entire folder including subdirectories. Otherwise, it deletes only file contents while preserving the directory structure. It skips any files matching your exclusion list. If configured, it then recursively deletes any empty subdirectories that remain.

Folder cleanup configuration requirements

  • Windows 8.1 or later, or Windows Server 2012 R2 and above

  • PowerShell 3.0 or later

  • Local administrator permissions to delete files from system folders and user profiles

  • Configuration of target folders ($targetFolders variable) for system-wide cleanup paths

  • Configuration of user folders ($userFolders variable) for per-user cleanup paths such as AppData\Local\Temp

  • Optional file extension exclusions ($exclude variable) to skip specific file types during deletion

Expected endpoint state after folder cleanup

After the Worklet completes successfully, your endpoints will have removed files from the specified folders according to your configuration. Disk space previously occupied by temporary files, cache, logs, or other excluded content is now available for productive use. Endpoints typically see improved performance due to reduced file system overhead and increased available storage. You can verify this change through the Automox Activity Log or by checking the endpoint configuration directly.

You can verify the results by checking available disk space, confirming that configured temporary directories are clean, or reviewing the Worklet's execution log. If you configured the Worklet to delete empty subdirectories, those directories are removed as well. User applications and system services continue to function normally since the Worklet avoids deleting files locked by running processes or protected system components.

How to validate folder clean up changes

  1. Run this Worklet on a pilot Windows endpoint and review evaluation output for folder clean up.

  2. Confirm Automox activity logs show successful completion and exit code 0.

  3. Verify endpoint state using checks aligned to evaluation script logic, such as the evaluation and remediation scripts.

  4. Validate remediation effects from script operations such as Get-CimInstance, Where-Object, Test-Path, then rerun evaluation for compliance.

View in app
evalutation image
remediation image

Consider Worklets your easy button

What's a Worklet?

A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

do more with worklets